[英]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);
}
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.