最近項目中用到強制退出App,做個筆記。
關鍵代碼
/** 退出App */ -(void)exitApplication { AppDelegate *app = (AppDelegate*)[UIApplication sharedApplication].delegate; //此處如果不強轉 AppDelegate,會報警告:Initializing 'AppDelegate *__strong' with // an expression of incompatible type 'id<UIApplicationDelegate> UIWindow *window = app.window; window.alpha = 0; window.frame = CGRectMake(0, window.bounds.size.width, 0, 0); exit(0); }
相關文章
iOS強制退出APP