Right now I'm trying storyboards out, and I have my UITableViewController
as my rootViewController
. Now on some instances if my user is not logged in, I want another UIViewController
to appear first. I understand I can perform a segue to it, but from my understanding the TableView
will still try to get loaded, which is not what I want unless they supply info on this UIViewController
that I'm trying to get to appear first (if say a key doesn't exist in NSUserDefaults
) for example.
So my question is, is there an easy solution I can maybe add to my appDelegate to "override" the rootViewController
from storyboard, or appear before it, then have a button simply on it to dismiss back to that rootViewController
in storyboard?
Thanks!
Really similar to this question: UIStoryboard load from app delegate
You should set the Storyboard ID in the Identity section of the View Controller in Interface Builder. Then you can get that screen via
You will end up with something like this:
An easy way would be to set your table sections to 0 if the user isn't logged in, for example;
You could:
Use a different initial view controller (you can specify this in the storyboard). In that view controller, check if the user is logged in. If they are, just transition directly to the table view controller via a manually triggered segue. If not, display the login screen.
Subclass UITableViewController. Check for the login in viewDidLoad. If not, present a modal login view controller.
You probably don't want to do it in the app delegate since that would require you to manually load the storyboard, which means unnecessary code.