简体   繁体   English

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

[英]How to exit the program after detecting user clicked the OK button on the UIAlertView

In my program, I have a code as below. 在我的程序中,我有以下代码。 How to exit the program after DETECTING user click OK on the UIAlertView? 检测用户后如何在UIAlertView上单击OK退出程序?

Thanks 谢谢

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

For getting the cancel (your "OK") button Implement this method: 为了获得取消(您的“确定”)按钮,请执行以下方法:

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

Check the QA here. 在此处检查质量检查。 see this tutorial 看到这个教程

if You want then use exit(0); 如果需要,请使用exit(0);

set AlertView delegate to self. 将AlertView委托设置为self。 and do your task in following delegate- 并完成以下任务,

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

For capturing the ok pressed, use this: 要捕获确定,请使用以下命令:

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

   exit(0);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM