iOS 程式碼關閉App
程式的死亡大致有三種:自然死亡,即無疾而終,通常就是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);
}
}
相關文章
- 批量關閉程式
- iOS 關閉系統自動更新iOS
- 使用screen讓關閉ssh連線時不關閉程式
- ios加固,ios程式碼混淆,ios程式碼混淆工具, iOS原始碼混淆使用說明詳解iOS原始碼
- 「iOS」行車服務app 「客戶端、後端思路+程式碼」iOSAPP客戶端後端
- ZBlog關閉驗證碼功能(出現驗證碼出錯請關閉)
- 開啟、關閉、切換App以及清除App程序,操作so easy!APP
- 開啟、關閉、切換 App 以及清除 App 程序,操作 so easy!APP
- win10怎麼強制關閉程式_win10怎麼關閉程式Win10
- win10如何關閉所有程式_win10怎麼一鍵關閉程式Win10
- App Clips,蘋果生態閉環的關鍵?APP蘋果
- 如何關閉Mac電腦APP的橫幅通知?MacAPP
- win10怎麼關閉卡死程式 win10程式卡死如何強制關閉Win10
- 程式人生:織夢dedecms後臺/會員驗證碼關閉
- iOS程式碼規範iOS
- win10怎麼關閉密碼_win10關閉登入密碼的方法Win10密碼
- win10怎麼關閉所有程式 win10關閉電腦所有程式如何操作Win10
- iOS 12.3開發者版更新,iOS上劃關閉動畫回來了iOS動畫
- [20191203]後臺程式dbrm關閉.txt
- LInux下檢視和關閉程式Linux
- go : channel , queue , 程式管理 , 關閉channel ?Go
- 關閉tomact被佔用的程式Mac
- 高通利用DMCA通知迫使GitHub關閉100多個程式碼庫Github
- iOS學習筆記01 APP啟動相關iOS筆記APP
- win10如何關閉工作管理員的registry程式_win10關閉registry程式的教程Win10
- 蘋果關閉了iOS 11.3系統的驗證通道蘋果iOS
- 瀏覽器掃碼開啟Android/iOS App瀏覽器AndroidiOSAPP
- iOS 程式碼注意事項iOS
- Swift iOS : 程式碼分析DrawControllerSwiftiOSController
- iOS 初探程式碼混淆(OC)iOS
- iOS逆向之 程式碼注入iOS
- iOS逆向 程式碼注入+HookiOSHook
- win10如何關閉dwm程式_win10怎麼關閉dwm.exeWin10
- 如何實現Spring中服務關閉時物件銷燬執行程式碼Spring物件行程
- golang程式優雅關閉與重啟Golang
- intellij 關閉後程式還在執行IntelliJ
- Spark閉包 | driver & executor程式程式碼執行Spark
- win10系統怎樣關閉pximouse程式_win10系統關閉pximouse程式的步驟Win10
- Ruby 中的閉包-程式碼塊