开发者

How to check alertview values

This is my code :

self.myAlert = [[[UIAlertView alloc] initWithTitle:@"MNB" message:@"R u want to delete" delegate:self cancelButtonTitle:@"OK",nil otherButtonTitles:@"Cancel",nil] autorelease];
    [myA开发者_运维百科lert show];

Here I would like to process if OK button click and also for cancel button, I would like to redirect the page if OK button clicked....I need the coding, IF condition statement when OK button clicked.....pls help me....


Read UIAlertViewDelegate Protocol Reference.

You can implement following methods.

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex


Just need to write the Delegate method of UIAlertView like this

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    if(buttonIndex==1){
              NSLog(@"Cancelled Clicked");  
         } 
    if(buttonIndex==0){
          NSLog(@"O.K Clicked");  
         }
}

Will surely work :)


You can use UIAlertView delegate methods. For example

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{
      if(buttonIndex == 0) //your OK button
      {
        //Some code here
      }
    else if(buttonIndex == 1)
      {
        //Some other code
      }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜