iOS 代码关闭App
来源:互联网 发布:淘宝上警服叫什么 编辑:程序博客网 时间:2024/06/05 11:35
程序的死亡大致有三种:自然死亡,即无疾而终,通常就是main()中的一个return 0;自杀,当程序发现自己再活下去已经没有任何意义时,通常会选择自杀。当然,这种自杀也是一种请求式的自杀,即请求OS将自己毙掉
方法一.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"退!出!" message:@"退出APP" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"退出", nil]; [alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if(buttonIndex ==1){ [self exitApplication]; }}-(void)exitApplication{ AppDelegate *app = [UIApplication sharedApplication].delegate; UIWindow *window = app.window; [UIView animateWithDuration:1.0f animations:^{ window.alpha = 0; window.frame = CGRectMake(0, window.bounds.size.width, 0, 0); } completion:^(BOOL finished) { exit(0); }]; //exit(0);}
方法二.
#pragma mark - 第二种方法- (void)exitApplication1{ [UIView beginAnimations:@"exitApplication" context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationDelegate:self]; // [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.view.window cache:NO]; AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate; [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:delegate.window cache:NO]; [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; //self.view.window.bounds = CGRectMake(0, 0, 0, 0); delegate.window.bounds = CGRectMake(0, 0, 0, 0); [UIView commitAnimations];}- (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { if ([animationID compare:@"exitApplication"] == 0) { exit(0); }}
项目 demo 下载,喜欢的朋友请给个 start
阅读全文
0 0
- iOS 代码关闭App
- iOS 通过代码关闭应用程序
- iOS 通过代码关闭应用程序
- iOS 通过代码关闭应用程序
- iOS 通过代码关闭应用程序
- iOS 代码规范~关闭警告
- 使用代码关闭APP“exit(0);”
- iOS关闭App带动画退出
- iOS关闭App带动画退出
- IOS 退出程序APP代码
- IOS 退出程序APP代码
- 代码退出IOS中App
- IOS 退出程序APP代码
- IOS 退出程序APP代码
- iOS-APP后台运行代码
- IOS 退出程序APP代码
- iOS 通过代码关闭应用程序
- 【代码笔记】iOS-UIAlertView自动关闭
- Scrapy Item Loaders机制详解
- 单例模式
- eclipse中应知道的一些快捷操作方式
- retrofit+RecyclerView+SwipeRefreshLayout下拉刷新上拉加载+item点击
- JavaScript 箭头函数(Lambda表达式)
- iOS 代码关闭App
- 浅析javascript中的this关键字
- Using cordova-fetch for cordova-android@6.2.2长时间无响应的问题
- 页面自动加载bootstrap的模态框
- Apriori定律
- uva 1354 Mobile Computing code2
- UGUI的优点新UI系统四 开源
- 【Zookeeper】3.Zookeeper环境搭建1
- 云原生:云计算时代命题之终极解决方案