iOS 通过代码关闭应用程序

估计大家都知道苹果手机退出应用程序是通过home键来控制的,那么代码能否使得程序退出程序呢?下面是利用代码控制使得程序退出. 
备注:这样调用能通过审核吗?

- (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:UIViewAnimationCurveEaseOutforView:self.window cache:NO];

    [UIViewsetAnimationDidStopSelector:@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);

    }

}

你可能感兴趣的:(iOS 通过代码关闭应用程序)