最佳答案
如果你想杀死你的应用程序,你可以调用:
exit(0);
However the app will look like it crashed. Apple don't recommend calling this function
如果你想在风格上做到这一点,你必须在 UIApplication 类中使用一些未记录的方法。 将此添加到您的标题
@interface UIApplication (Private)
- (void)suspend;
@end
然后你就可以这样调用它了
//this will animate the app to home screening won't quit it
[[UIApplication sharedApplication] suspend];
您可以在调用退出应用的方法后设置一个定时器
NSTimer* myTimer = [[NSTimer alloc] initWithFireDate:[NSDate date]
interval:0.4
target:self
selector:@selector(suspendTimeout:)
userInfo:nil
repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];
- (void)suspendTimeout:(id)sender{
exit(0);
}
关于ios - 如何从处理 iPhone 上的应用程序中消失应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37917453/