0

I have a viewcontroller, i named it as SelectionPopUpViewController. I embed that controller on a UINavigationController.

controller picture

From SelectionPopUpViewController.swift, I put:

@IBAction func okTapped(sender: AnyObject) {
    self.dismissViewControllerAnimated(false, completion: nil)
    let homeVc = UIStoryboard(name: "Home", bundle: nil).instantiateViewControllerWithIdentifier("Home") as HomeViewController
    self.navController = UINavigationController(rootViewController: homeVc)
    self.window?.rootViewController = self.navController
    //self.navController.pushViewController(homeVc, animated: true)
}

on above I put :

weak var window : UIWindow?
var navController : UINavigationController!

What I want is when user click that okTapped button, it will go to HomeViewController. I try to initialize like that but it did not work. Maybe my initialization wrong.

What is the correct code to made that button work (go to HomeViewController)?

AdrieanKhisbe
  • 3,532
  • 7
  • 31
  • 45
Crocodile
  • 13
  • 7
  • If you want to go back to main screen again please have a look at the question i asked few months ago, this may help http://stackoverflow.com/a/25922738/4056108 – chirag90 Mar 31 '15 at 09:08
  • tried with navController.popToRootViewControllerAnimated(true), it give nil and it did not go to HomeViewController. – Crocodile Mar 31 '15 at 09:18
  • Is your navigation controller set as root controller? – chirag90 Mar 31 '15 at 09:20
  • like this: self.navController = UINavigationController(rootViewController: homeVc) ? – Crocodile Mar 31 '15 at 09:26
  • HomeViewController and SelectionPopUpViewController are different navigation controller, but in the same storyboard. – Crocodile Mar 31 '15 at 09:56

0 Answers0