1.
-(void) animationfinished: (nsstring*) Animationid finished: (nsnumber*) Finishedcontext: (void*) context{if([Animationid Compare:@"exitapplication"]==0) {exit (0);//Exit ApplicationNSLog (@"Stop"); }}-(Ibaction) Exit: (ID) sender{[uiviewbeginanimations:@"exitapplication"Context:nil];//Animation name[Uiviewsetanimationduration:6]; [Uiviewsetanimationdelegate:self]; [UIViewsetAnimationTransition:UIViewAnimationCurveEaseInOutforView:self.viewcache:NO]; //Animation mode//actions performed by the end of the animation[Uivie setanimationdidstopselector: @selector (animationFinished:finished:context:)]; Self.view.bounds=cgrectmake (0,0,0,0);//End of animation[uiviewcommitanimations]; }
2.
-(void) exitapplication { *app = [uiapplication sharedapplication]. Delegate; *window = App.window; [UIView animatewithduration: 1.0f animations:^{ 0; = CGRectMake (000); } completion:^(BOOL finished) { exit (0); }]; }
3.
Q: How to Exit iOS program in code mode A: There are no APIs available to exit the iOS app normally. in iOS, the user clicks the home key to close the app. Your app should meet the following criteria: it cannot invoke the method itself, but should take steps to interact with the user, indicating the nature of the problem and the behavior that the application might take, such as turning on WiFi, using location services, etc. for the user to choose to use; warning: Do not use the Exit function. Calling exit will cause the user to feel that the program is crashing, that there will be no smooth transitions and animations when the home key is returned, and that using exit may result in loss of data because calling exit does not call -applicationwillterminate: Methods and Uiapplicationdelegate methods, and the Abort function and the Assert macro are recommended if you do need to forcibly terminate the program in development or testing .
IOS Program Switching background