How to show tutorial or login screen upon app launch (without flashing)

So, you want to show a tutorial or login screen as soon as your app launches without flashing your main view controller first?

Go no further!

This might seem hard at first but let me assure you, it is not. So, let’s see how it’s done:

Go to your storyboard and set your login screen or tutorial screen as the Initial View Controller.

Now go to your AppDelegate.m and add this code in your didFinishLaunchingWithOptions:

You want to show your login screen or tutorial screen based on some criteria, which for the sake of this tutorial is whether the app is launched for the first time or no. For this we are checking a key in the user defaults, which we set once the app is launched. If the key exists, the app is not launched for the first time, thus we should not show the tutorial screen. (I am using an integer here but any type will be fine because we are checking for it’s existence not it’s value).

Tip: If you use a BOOL instead of an integer, checking for it’s existence might not work this way. If (BOOL) will return NO if the BOOL is set to NO and will return NO even if the BOOL is non existent.

Now, to actually present our main view controller instead of the tutorial or login screen, all we have to do is set it as the root view controller for the AppDelegate.

Thanks for reading and feel free to comment guys!

Leave a Reply

Your email address will not be published. Required fields are marked *