官方SDK方法(突然消失,但在长按APP列表中依旧出现快照):

exit(0); // 退出APP

带动画效果的退出:

- (void)exitApplication {  
    [UIView beginAnimations:@"exitApplication" context:nil];  
    [UIView setAnimationDuration:0.5];  
    [UIView setAnimationDelegate:self];  
    [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.window cache:NO];  
    [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];  
    self.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);  
    }
}
AppDelegate *app = [UIApplication sharedApplication].delegate;
UIWindow *window = app.window;
    
 [UIView animateWithDuration:0.4f animations:^{
     window.alpha = 0;
     CGFloat y = window.bounds.size.height;
     CGFloat x = window.bounds.size.width / 2;
     window.frame = CGRectMake(x, y, 0, 0);
} completion:^(BOOL finished) {
     exit(0);
}];

Private API:

[[UIApplication sharedApplication] terminateWithSuccess];
\\ 或者
[[UIApplication sharedApplication] performSelector:@selector(terminateWithSuccess)];

 

 

2 对 “[iOS]主动退出APP方法”的想法;

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注