BarButton ItemNot Showing iOS 13 XCode 11.5

Beginner Alert: I’m trying to check if my user has previously logged in or not. For this, I have used User Defaults, which seems to be working fine. The problem is when I initialize my view controller in Scenedelgate, it only brings up a blank screen. The code doesn’t seem to be the problem. Rather it’s just that the bar button and label I have in my HomeController aren’t showing. I already tried setting its tint and background color, but that hasn’t changed anything.

Here is my code for the scene delegate:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
     guard let windowScene = (scene as? UIWindowScene) else {return}

     let def = UserDefaults.standard
     let is_authenticated = def.bool(forKey: "is_authenticated") // return false if not found or stored value

      if is_authenticated {
      // user logged in
          let window = UIWindow(windowScene: windowScene)
          window.rootViewController = UINavigationController(rootViewController: HomeViewController())
          self.window = window


Here’s how my user defaults function looks like:

 func saveLoggedState() {

let def = UserDefaults.standard
def.set(true, forKey: "is_authenticated") // save true flag to UserDefaults


Here’s how my simulator looks:

Here’s how my view controller should look:

Thank you for any advice that you can give. I’m a complete newbie so I don’t really know what I’m doing when it comes to this. Any help appreciated.


Hi @Gryffin

Do you want to share you code so that I can take a look for you?

Do you want the whole project? Or just some specifics? Thanks!

The whole project so that I can see what is happening when you instantiate the HomeViewController.

Share it via DropBox or Google Drive.

(edit) If you share it via DropBox you can paste a share link in a reply. If you share it via Google Drive I can provide you with an email address by PM.

Hi Chris, I was just debugging some of the code and I realized that the thing isn’t working is the line of code that says @IBAction:

override func viewDidLoad() {
        view.backgroundColor = .white
        print("Run 1")
        sideMenu.leftSide = true
        SideMenuManager.default.leftMenuNavigationController = sideMenu
        SideMenuManager.default.addPanGestureToPresent(toView: view)
        print("Run 2")
    @IBAction func tappedMenu() {
            present (sideMenu, animated: true)
        print("Run 3")

Compared with the other snippets of code I posted, I think these make up the relevant things pertaining to my situation. Do you still need more code?

Is the fundamental issue the fact that the menu button is not visible?

Yes, the issue is that the menu button isn’t showing up
Edit: I checked, for some reason the function isn’t even being called at all

So that means that the button is not there at all. Is that right?

Yes, it’s on the storyboard but it’s not showing up in the simulator. I also connected the button as well to the storyboard but no hope. If the user is logging in for the first time, you can see the side menu button, but otherwise no

That’s a bit weird that in one case you see it but in other cases you don’t.

I still think there is a problem with doing what you are trying to do in SceneDelegate. I’m not so sure that SceneDelegate is referenced all the time during the Apps life cycle.

Thanks, Chris. But my print statements seem to be working fine when I placed them in the scenedelagate to check if the code in between is being called

That still leaves the issue of why the HomeVC is not playing the game.

Yes, you’re right. Do you have any idea why?

I’m a bit bushed (an Australian slang word meaning “lost”) on that at the moment. You still want to share the project so I can take a look?

Sure, can you share me the email address? I don’t have a dropbox account.

I sent you a private message so to see that you need to tap on your user image icon up at the top right of screen and select the Messages tab.

1 Like

What is your timezome Gryffin?

I’m in Western Australia so it UTC + 8

I’m UTC - 6. All the way over on the other side of the world