2

Possible Duplicate:
How do I kill a back ground running app in iphone?

When the user click on home button in the user's iphone, how to terminate my apps in xcode. So when the user click on the apps, it should be in the splash screen again. Please help.

-(BOOL)application:(UIApplication *)application   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

sleep(3);

MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];

self.myViewController = aViewController;

[aViewController release];

self.window.rootViewController = self.myViewController;

// Override point for customization after application launch.


[self.window makeKeyAndVisible];

return YES;


}
Community
  • 1
  • 1
Noob
  • 55
  • 3
  • 10

3 Answers3

2

As per my answer to another, similar, question:

Using an Info.plist property UIApplicationExitsOnSuspend you can prevent your app from entering background and terminating as was the norm prior to iOS 4. You can read more about Info.plist keys to learn about additional options.

If you do not want your application to remain in the background when it is quit, you can explicitly opt out of the background execution model by adding the UIApplicationExitsOnSuspend key to your application’s Info.plist file and setting its value to YES

Community
  • 1
  • 1
Ryan Wersal
  • 3,210
  • 1
  • 20
  • 29
  • Yes. It works. But do you think they will reject my apps? because I am adding 'application does not run in the background' in plist? – Noob May 20 '11 at 03:58
  • They definitely won't reject it, however, they would prefer that all apps support multitasking as it is what their users expect in this post-iOS4 world. – Ryan Wersal May 20 '11 at 04:10
1

Apple will reject your app if you try to terminate it force fully when it enters in background.

saadnib
  • 11,145
  • 2
  • 33
  • 54
  • Do you think they will reject my apps? because I am adding 'application does not run in the background' in plist? – Noob May 20 '11 at 03:58
  • 1
    Apple will reject if you do something like `exit(0);` or purposefully crash your app to exit. The only accepted exit mechanism is the home button at the bottom of the device. – Ryan Wersal May 20 '11 at 04:12
1

Well I can tell you that you really can't do much about this because terminating protocols are private api's and will not be accepted by iTunes Connect, but if your planning on putting this on Cydia or Installous then here are a couple of them... hope this helps.

[[NSThread mainThread] exit];
[[UIApplication sharedApplication] terminate];
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281