可能重复:
退出 iPhone 应用程序的正确方法?
如何使我的应用程序崩溃?
如果用户在此代码中按下关闭,我想使应用程序崩溃
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Alert!"
message:@"What To Do To You App!"
delegate:self
cancelButtonTitle:@"Close"
otherButtonTitles:@"Open In Safari",nil];
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1)
{
NSLog(@"Open in Safari");
}
else
{
NSLog(@"Close");
}
}