Believe in your own future, will thank yourself right now Sinner Yun

Sinner_Yun

APP强制退出

第一种方法:

企业版可以用,Appstore可能被拒,慎用

 

 1 - (void)exitApplication {
 2     
 3     AppDelegate *app = [UIApplication sharedApplication].delegate;
 4     UIWindow *window = app.window;
 5     window.backgroundColor = [UIColor redColor];
 6 
 7     
 8     [UIView animateWithDuration:1.0f animations:^{
 9         window.alpha = 0;
10         window.frame = CGRectMake(0, window.bounds.size.width, 0, 0);
11     } completion:^(BOOL finished) {
12         exit(0);
13     }];
14     
15 }

 

第二种方法 - 推荐,官方例子经常出现

 

1       [self performSelector:@selector(sayByeBye)];
2      
3 
4 -(void)sayByeBye{
5     abort();
6 }

 第二种方法用模拟器测试不出来。只能真机。把第一个的exit 替换 abort也有动画效果;

 

posted on 2016-02-19 10:42  Sinner_Yun  阅读(376)  评论(0编辑  收藏  举报

导航