Search code examples
swiftstoryboardsegue

Swift Storyboard - how to not present modally


I am checking to see if user logged in or is already logged in. If they are, I implement this code:

                        //self.performSegue(withIdentifier: "LogInToTagsy", sender: nil)
                        let storyboard = UIStoryboard(name: "Main", bundle: nil)
                        let vc = storyboard.instantiateViewController(identifier: "tabBarController")

                        self.show(vc, sender: self)

I tried the commented out line as well. (and had a segue of kind "show" in storyboard). Both options are presenting modally. I do not want this. How do I present normally?

I also have tried embedding in a navigation controller, and it gave me two nav bars for all screens. Let me know if you need more info, thank you. storyboard screenshot

When embedded in Nav Controller


Solution

  • Your controller from which you are calling the show() code should be navigation controller thats how you can achieve normal push instead of modally present. So in your case either you are calling this code from first tap bar item controller or second items controller ... that controller should be embed in navigation

    And instead of self.show(vc, sender: nil) it should be

    self.navigationController?.show(vc, sender: nil)