adriaan
adriaan

Reputation: 1594

Reinitializing iPhone app when it relaunches

I am building an iPhone app. Currently when I close the app and relaunch it, it relaunches on the last viewed view. Instead I want to be able to reinitialize the app, and present the view that's most appropriate for the application's state (based on what's in the database).

How can I do that?

Upvotes: 1

Views: 196

Answers (2)

Seamus Campbell
Seamus Campbell

Reputation: 17906

You have two options. You can follow Petesh's suggestion to make your app always terminate, or you can implement -applicationWillEnterForeground in your app delegate and reset things there.

Upvotes: 2

Anya Shenanigans
Anya Shenanigans

Reputation: 94584

I presume it's iOS4 - your app is not being terminated in this case, it is merely being suspended.

You need to follow the instructions here: http://maniacdev.com/2010/07/screw-multi-tasking-how-to-make-your-ios-4-apps-exit-for-real/ which will terminate the app when the user presses the home button.

You need to add the appropriate 'correct view' logic to your application's start-up code once you've done this.

For the purposes of expediency, I'm adding the instructions here:

  1. Open your info.plist file
  2. Add The Key UIApplicationExitsOnSuspend or Select Application does not run in background
  3. Set the new key to YES or Fill in the tick box

Upvotes: 1

Related Questions