I am engaged on a easy app that presently has only one fundamental view controller plus a settings view controller.
The settings view controller is embedded inside a navigation controller and has 2-3 inside view controllers (totally different settings pages).
Present app habits:
- I am in one of many settings screens
- I reduce the app/transfer it to the background and open one other app for a second
- I return to the app, which reloads into the primary view controller (i.e. the display the person would see if they simply launched the app)
Desired app habits:
- When returning to the app, reload into whichever display was final getting used (e.g. if I used to be in one of many settings screens, load into that one once more)
I learn this documentation and applied the next code in my app delegate:
func utility(_ utility: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool
{
return true
}
func utility(_ utility: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool
{
return true
}
)
I additionally made certain that every one my view controllers have a Restoration ID
within the storyboard builder of Xcode.
The documentation mentions overriding the next capabilities in relevant view controllers: encodeRestorableState(with coder: NSCoder)
and decodeRestorableState(with coder: NSCoder)
, however I am undecided if this precisely applies to my app.
Within the settings view controllers, there isn’t a such data the person can be typing in or modifications they may make apart from doing issues like toggling switches. These modifications can be saved to UserDefaults
, so so long as the app reloads into these screens, their modifications can be mirrored nonetheless.
How can I get my app to reload into whichever display it was on when minimized, as an alternative of all the time reloading into the preliminary view controller?