Reputation: 1152
Is there any way to disappear an running app on processing on iPhone? Like this photo below. e.g. App Store application is my own application. I wanna do disappear it when I double clicked the home button. Any help is appreciated!
Upvotes: 0
Views: 76
Reputation: 1631
If you want to kill your application you can call:
exit(0);
However the app will look like it crashed. Apple don't recommend calling this function
If you want to do it in style you have to use some undocumented methods in UIApplication class. add this to your header
@interface UIApplication (Private)
- (void)suspend;
@end
And then you can call it like tis
//this will animate the app to home screening won't quit it
[[UIApplication sharedApplication] suspend];
You can set a timer after calling the method to quit the app
NSTimer* myTimer = [[NSTimer alloc] initWithFireDate:[NSDate date]
interval:0.4
target:self
selector:@selector(suspendTimeout:)
userInfo:nil
repeats:NO];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];
- (void)suspendTimeout:(id)sender{
exit(0);
}
Upvotes: 1