【问题标题】:How To Crash An App [duplicate]如何使应用程序崩溃[重复]
【发布时间】:2012-05-20 21:21:11
【问题描述】:

可能重复:
Proper way to exit iPhone application?

如何使我的应用崩溃?

如果用户在此代码中按下关闭,我想使应用程序崩溃

    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");
}
}

【问题讨论】:

  • 故意崩溃的方法有无数种。在此处查看有关崩溃的任何问题以获取有用的示例代码。
  • 最简单的一个:int hellYeah = 1/0;
  • 它只是让应用程序崩溃,因为应用程序不是官方版本
  • 这是代码thnx [[NSThread mainThread] exit];

标签: ios crash


【解决方案1】:

在代码附近除以零怎么样!

【讨论】:

  • 您的意思是您的应用可以除以零吗?!
【解决方案2】:

使用-

[[NSThread mainThread] exit];

【讨论】:

  • 感谢这对我很有帮助
【解决方案3】:

您不应在 iOS 上添加关闭/退出应用的按钮。

【讨论】:

  • 应用被破解时我用它关闭应用
猜你喜欢
  • 2023-03-21
  • 2018-10-07
  • 1970-01-01
  • 1970-01-01
  • 2014-07-07
  • 1970-01-01
  • 2013-09-17
  • 2018-03-16
  • 2015-01-09
相关资源
最近更新 更多