我们的APP有一个功能是退出应用,之前交给外包做的时候,他们只负责实现功能,但是没有考虑到功能的优化问题,于是直接用崩溃退出的方式。
而我接手之后,有一种更好实现的方法:
- (void)exitApplication {
//直接退,看起来好像是 crash 所以做个动画
[UIView beginAnimations:@"exitApplication" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view.window cache:NO];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
self.view.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);
}
}
仅供需要实现该功能的小伙伴儿们参考~