App优雅闪退如同按了home键
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"友好提示" message:@"发现新的补丁,是否需要安装补丁?安装完需重启应用,请选择..." preferredStyle:(UIAlertControllerStyleAlert)];
[alertVC addAction:[UIAlertAction actionWithTitle:@"更新补丁" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
dispatch_async(dispatch_get_main_queue(), ^{
//私有api 回到桌面如同按了Home键
[[UIApplication sharedApplication] performSelector:@selector(suspend)];
//加点延时等动画结束再闪退
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.26 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
exit(-1);
});
});
}]];
[alertVC addAction:[UIAlertAction actionWithTitle:@"下次再说" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
}]];
[self.window.rootViewController presentViewController:alertVC animated:YES completion:nil];
未经作者授权,禁止转载
本文来自博客园,作者:CoderWGB,转载请注明原文链接:https://www.cnblogs.com/wgb1234/articles/17486440.html
THE END