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.
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
Post a Comment