Learn Courses My Dashboard

How to set a different View Controller as the initial controllerr?

Hi Everyone! I recently watched a CodeWithChris Youtube video where we created a log in screen with Firebase and once the users logged in it would take them to a home page.

This is the video above. I am trying to expand on this home page to link to a navigation controller however it is not working. Based on my research it seems that I need to change the home screen to be the initial controller. I am pretty sure I need to add code here in order for this to work.

Any suggestions or help would be greatly appreciated!!!

Welcome to the community @lena !

In your storyboard file, click on the view controller that you want to be the initial VC, in the attributes on the right pane, there’s a checkbox for “is initial view controller” check that

Thank you so much for the welcome! I tried that and it did not work because I have a log in screen that is the initial view controller. See screenshot below, here is my setup. It goes from the log in screen and then once it successful log ins it goes to the Dealz page with the search bar. That part works fine but I need to change this page to an initial page in order to use the navigation control. Or is there away I do not need to do that?

Which one needs to be the initial? Can you circle it in your screenshot, I can’t tell

So your login screen being first works and it goes to the Dealz VC after.

Then which one needs to be the initial? What do you mean?

Yes of course! Sorry, I was not specific in my photo. This should be a better photo. So after it logs in it will go to the second initial screen. I tried to set a navigation controller to it but it did nothing when it came to making it an initial controller.

Ohhhh okay

So the login should always be the initial view controller

And you can save a value called a “user default” that if the user is already logged in to go to the 2nd screen. Kinda like how you had the first screenshot with the code. But that code should be in your app or scene delegate, not in the view controller

Does your app have a SceneDelegate and AppDelegate file? Is it targeting iOS 13 or 14?

ohhh, that definitely makes sense! Yes, I do have a SceneDelegate and AppDelegate. Where would I put that code. I never touched these files before and I am slightly confused where to put that.

This article can help!

These files are all about your app’s lifecycle.

Thank you so much! I will take a look at this!