I would like to move back to my main view using a segue. When the home button is pressed and the app enters the background…. then later the user wishes to open the application again bringing it to the foreground I would like a segue to be run which takes them from whatever view they were in back to the ‘main view’. I dont mind using multiple segues… or how could I access these segues in the app delegate for example.
What is the best method for this? Thankyou! beer and points for everyone who gives a good answer ;).
You may implement the
applicationWillEnterForeground:application:method (from the UIApplicationDelegate protocol). This method is called whenever your application’s state changes from backgo to inactive state (before it goes to active).In this method you could call
performSegueWithIdentifier:identifier sender:. If you have a segue from each possible view back to your main view, your are done.However, unless your application has a very complex state that would need lots of time to reconstruct, I would recommend to do general a re-initialization of your application in
application:didFinishLaunchingWithOptions:orapplicationDidBecomeActive:. In this way it is easier to preserve a consistent state.