iOS 通过代码关闭应用程序

Posted on 2013-07-30 18:56  冰天雪域  阅读(277)  评论(0编辑  收藏  举报
- (void)exitApplication {

    [UIView beginAnimations:@"exitApplication" context:nil];

    [UIView setAnimationDuration:0.5];

    [UIView setAnimationDelegate:self];

    // [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.view.window cache:NO];

    [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.window cache:NO];

    [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];

    //self.view.window.bounds = CGRectMake(0, 0, 0, 0);

    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);

    }

}


Copyright © 2024 冰天雪域
Powered by .NET 9.0 on Kubernetes