xcode - Swift ios set a new root view controller -


i wonder if possible set new root vc?

my app gets init uinavigation controller has table view root vc.

then table view running segue login window (present modally) if login end in red vc/account page. want set red vc new root vc of app, , remove underlying vc's. can show menu button/icon instead of "back" button

i have found dont understand how use it:

let storyboard: uistoryboard = uistoryboard(name: "main", bundle: nsbundle.mainbundle())         let yourviewcontroller: viewcontroller = storyboard.instantiateviewcontrollerwithidentifier("respectiveidentifier") as! viewcontroller          let navigationcontroller = self.window?.rootviewcontroller as! uinavigationcontroller         navigationcontroller.setviewcontrollers([yourviewcontroller], animated: true) 

but cannot work. possible make red vc in picture act new root vc.

enter image description here

may should try this

 let mainstoryboard = uistoryboard(name: "main", bundle: nil)  let redviewcontroller = mainstoryboard.instantiateviewcontrollerwithidentifier("respectiveidentifier") as! viewcontroller  let appdelegate = uiapplication.sharedapplication().delegate as! appdelegate  appdelegate.window?.rootviewcontroller = redviewcontroller 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -