user471416
user471416

Reputation:

close (minimize) app from code

how can i close or minimize my app from code like when i push home button?

Upvotes: 1

Views: 2769

Answers (6)

fibnochi
fibnochi

Reputation: 1113

[[UIApplication sharedApplication] terminateWithSuccess];

Compiler will give warning. you should ignore it. This will work.

Upvotes: 0

hotpaw2
hotpaw2

Reputation: 70733

To minimize your app using an approved API, launch another app, for instance Safari, using a registered URL.

Upvotes: 1

Vanya
Vanya

Reputation: 5005

Ok, I guess I got your question.

Yes that is correct you don't need any special code when pressing home button to exit app. And yes that is correct that exit (0) can make it from the code.

- (void)vypni
{
    exit(0);    
}

What is not correct that your app will be reject. I use exit (0) in my code and the app with it is available on the app store now. I guess if you take good management around what should be done (disable timers, etc) it can be used.

Upvotes: 0

ingh.am
ingh.am

Reputation: 26812

You can use exit(0) but your application will be rejected if you submit it to the App Store. This is because the guidelines state that a user should only be able to exit the application by pressing the home button.

EDIT: This is pretty much a duplicate of this. Much more discussion here...

Upvotes: 0

Kai Huppmann
Kai Huppmann

Reputation: 10775

You don't have to do anything, it'll be done by the framework

Upvotes: 1

Swapnil Luktuke
Swapnil Luktuke

Reputation: 10475

exit(0); will close your app. Its not recommended though.

Upvotes: 2

Related Questions