之前一直没有遇到过需要直接在程序中退出应用程序的情况,今天有这个需求,我在网上查了一下,代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// 退出当前程序 - ( 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:UIViewAnimationTransitionCurlDown forView: self .view cache: NO ];
[UIView setAnimationDidStopSelector: @selector (animationFinished:finished:context:)];
//self.view.window.bounds = CGRectMake(0, 0, 0, 0);
self .view.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);
}
|
其实只需要一句哈就可以了 ,如果嫌麻烦的话可以直接使用
exit(0);