公司的应用总共有三个生产环境,测试,UAT,和正式的。每个环境都打个包,上传 蒲公英 或者 fir,测试组要每个版本都下载一个,太麻烦,然后测试组老大希望加一个在应用内直接切换环境的功能。切换环境后需要让应用退出下,上网搜到这样的代码:
- (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);
}
}
下篇见~