I'm developing an app (in Swift with UI builder) where I have a UITableViewController embedded in a UINavigationController so I can present details about the rows, use a standard '+' button to add rows to the table etc. At that point, the UINavigationController is the entry point to the storyboard.
Now I want to add a login screen as a UIViewController before the UITableViewController in the storyboard, so the user needs to log in first and, upon successful authentication, would be taken to the table view. I'm expecting the new view controller should be embedded within the existing navigation controller (makes sense to me for the sake of continuity). However, I can't figure out how I can insert the login screen within the navigation controller without breaking the existing navigation. I've tried several approaches, e.g. creating a new segue from the login screen to the table view, then replacing the relationship "root view controller" between the navigation controller and the table view with a new one with the login screen, but when I do this all the navigation elements in the table view and the subsequent screens (details, data creation) disappear.
Is there a trick to doing this, or will I have to recreate the whole navigation logic?
Thanks!
Sounds like you're on the right track... not sure where you're going wrong.
This would be (one) valid approach, and should give you what you're going for.
Edit: Note also, if you are navigating via code, you want to PUSH ViewControllers onto the Navigation stack, not "present" them. E.G.: self.navigationController?.pushViewController(tableViewController, animated: true)
Start with NavController... TableView is Nav's Root, and DetailView is shown on Table Row Select:
Delete the "Root VC" connection, and drop a new ViewController in-between - should look about like this now:
TableView and DetailView are missing the NavBar at the top - that's OK.
Now, connect the LoginView as Nav's Root, and connect a Show segue from Login Button to TablView:
If all goes according to plan, NavBar is again showing at the top of TableView and DetailView, as desired.