Search code examples
iosswiftuinavigationcontroller

Swift: Initial controller should be child of navigation controller


I'm creating an iOS app. When the app starts, it should open the second VC in the navigation stack. The navigation bar should show the back button that leads to the main navigation controller.

It should look like the Calendar app on iPhone. When you open this app, it shows the week/day-look, and when you tap the back button, it shows the month-look.

I can't figure out how to do this. How is this possible?


Solution

  • You can simply do this..

     override func viewDidLoad() {
            super.viewDidLoad()
            perform(#selector(self.presentSecondVC), with: nil, afterDelay: 0.1)
        }
    
        @objc func presentSecondVC(){
    
                self.performSegue(withIdentifier: "yourSegueIdentifier", sender: nil)
        }