The delegate method "clickedButtonAtIndex:" is not called.

Posted by sagiftw on Stack Overflow See other posts from Stack Overflow or by sagiftw
Published on 2010-03-29T13:00:45Z Indexed on 2010/03/29 13:03 UTC
Read the original article Hit count: 145

Hello everyone!

I have created an alert view with two buttons using the following code:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: title 
message: msg delegate:nil cancelButtonTitle:@"Replay" otherButtonTitles:@"Highscore", nil];
[alertView show];

I want to run some code when one of the buttons is clicked. In order to do so, I have added the following method to the delegate.m file:

 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
 if (buttonIndex==0) //Run some code 
 else //Other code
 }

But this method is not called when I press either of the buttons! Can someone tell me why?

Thanks in advance,

Sagiftw

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk