-1

I am building an Onboarding/Welcome screen for my app, but the problem is that my app has a tab bar, so my Onboarding somehow interferes with that and doesn't look like a seamless interface. My solution is to put the Onboarding thing on a separate view controller and once a user is done with that screen, it presents the navigation controller and all of ITS views. I have done some research on this, but I'm still lost. If you have any other ideas, or have solutions, please let me know, thanks.

Here is what I want to achieve: This

Fogmeister
  • 76,236
  • 42
  • 207
  • 306

1 Answers1

0

In order to do this in a way that looks nice and works well you should not be pushing or presenting the tab bar but updating the root view controller of the whole window.

I can’t provide a code example right now but there will be several online sources for this.

You should be changing the view controller so it essentially toggles the app between “logged in” and “logged out”.

That way you don’t have to worry about how to get from one to the other. They act separately just dealing with their own stuff.

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
  • I haven't really understand the root viewcontroller concept, could you please elaborate? – CoolCrafts Bayarea Jun 22 '22 at 22:23
  • https://developer.apple.com/documentation/uikit/uiwindow/1621581-rootviewcontroller Your onboarding vc is the app’s root view controller right now. You are trying to push on top of that. But what I’m saying is don’t do that. Swap out the onboarding root view controller when the log in happens so that the tab bar controller is now the root. – Fogmeister Jun 22 '22 at 22:29
  • So when the user is logged in the onboarding part of the app is gone. It just doesn’t exist anymore. Instead of the login screen still being there underneath everything else. – Fogmeister Jun 22 '22 at 22:30
  • Is the "initial view controller" the root vc? – CoolCrafts Bayarea Jun 22 '22 at 22:32
  • Correct. By using a storyboard like this you are bypassing what is actually happening in the app. you cannot do what I am suggesting only in a storyboard. You will need to write code to do this. – Fogmeister Jun 22 '22 at 22:33
  • This question explains what I’m referring to https://stackoverflow.com/questions/41144523/swap-rootviewcontroller-with-animation – Fogmeister Jun 22 '22 at 22:35
  • 1
    Yes, I know... I was just trying to understand the concept, I usually write things programmatically. – CoolCrafts Bayarea Jun 22 '22 at 22:38
  • Sorry, didn’t mean to sound like I was being argumentative or anything like that. Was just pointing it out but reading back it seemed a little short. Apologies. – Fogmeister Jun 22 '22 at 23:47
  • No need to apologize, all good – CoolCrafts Bayarea Jun 22 '22 at 23:49
  • @Forgmeister I like your method, but I tried digging in a little more, and couldn't find any other resources to swap view controllers. Could you please help me out... – CoolCrafts Bayarea Jun 24 '22 at 01:27
  • Here you go… https://qnoid.com/2019/02/15/How_to_replace_the_-rootViewController-_of_the_-UIWindow-_in_iOS.html – Fogmeister Jun 24 '22 at 05:35
  • the link doesn't work – CoolCrafts Bayarea Jun 25 '22 at 18:38
  • It’s because of the formatting that stack overflow has done to it. Copy and paste the whole thing. – Fogmeister Jun 26 '22 at 10:27