如何在检测到用户单击UIAlertView上的“确定”按钮后退出程序



在我的程序中,我有一个代码如下。DETECTING用户单击UIAlertView上的OK后,如何退出程序?

感谢

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"YOur Message" message:@"Your description"
                                               delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];

用于获取取消(您的"OK")按钮实现此方法:

 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
 {
      if(buttonIndex == 0)
          exit(0);
    }

在此处检查QA。请参阅本教程

如果需要,则使用exit(0);

将AlertView委托设置为self。并在以下代表中完成您的任务-

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

要捕获按下的ok,请使用以下命令:

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
   exit(0);
}

最新更新