I have an iOS app that consists of an "Overview" scene as the initial view controller, an "EntryList" scene, and a "NewEntry" scene. They are organized with a navigation controller and connected in the mentioned order, using show (push) segues. The NewEntry view controller has "Save" and "Cancel" menu bar items that unwind to the EntryList controller.
I added a Quick Action to the app icon that directly jumps into the NewEntry controller by using performSegueWithIdentifier
with a segue that goes from the navigation controller to the NewEntry controller.
When the Quick Action is used after the application had been suspended from running, the new NewEntry instance ist pushed onto the navigation stack, regardless of the previous contents. So, even multiple NewEntry instances can be stacked. In this case, any remaining old NewEntry instances could be discarded.
When the Quick Action is used after the application had been terminated, a new Overview instance is always created first (because of being the first actual VC after the initial navigation controller, I suppose?), and then the NewEntry is pushed. No EntryList scene in this case.
When either the Cancel or the Save item is pressed, the NewEntry scene shall be discarded and acted upon appropriately, leaving the user either in the state the app had before, or in the overview scene otherwise.
My questions:
- What would be the correct behavior an application should perform?
- How do I achieve that behavior?
- What is "best practice" to implement all segues, especially when the NewEntry scene is not necessarily pushed after the EntryList scene?
I want to steer clear of "UI spaghetti code", navigation stack hacking, etc.