uinavigationcontroller - navigationController is nil in swift -


i have 2 storyboard (main , sb2)

i have 1 view controller in storyboard in main , 1 in sb2 perform

let sb2 = uistoryboard(name: "sb2", bundle:nil) let vc : uiviewcontroller = self.sb2.instantiateviewcontrollerwithidentifier("vc2") self.showviewcontroller(vc, sender: self) 

after second viewcontroller loads , command run, prints nil:

print(self.navigationcontroller) // prints nil 

in sb2 (second storyboard) clicked on viewcontroller (vc2) , clicked on editor > embed in > navigation controller. placed navigation controller storyboard , root view controller vc2. triple checked this. first sign of being connected gray navigation bar on top. second being there segue connecting navigation controller vc2 , last place have checked in navigation controller utilities.

i thinking maybe shouldn't transition vc1 vc2 directly rather vc1 navigationcontroller don't know how or if possible.

i don't know when sb2 prints nil when in face navigation controller connected it. appreciated.

you need push view controller (vc2) on navigation controller.

let sb2 = uistoryboard(name: "sb2", bundle:nil)v let nvc = sb2.instantiateviewcontrollerwithidentifier("nvc") as! uinavigationcontroller let vc : uiviewcontroller = self.sb2.instantiateviewcontrollerwithidentifier("vc2") nvc.pushviewcontroller(vc, animated: true) 

then in view controller try calling

self.navigationcontroller 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -