uitabbarcontroller - how to close a tabbar swift -
i have login view controller on correct login open tabbar controller following method:
self.dismissviewcontrolleranimated(true, completion: { self.loadhomescreen()}) func loadhomescreen() { emailfield.text = "" passwordfield.text = "" self.presentviewcontroller(uistoryboard.tabbarcontroller()!, animated: true, completion: nil) } private extension uistoryboard { class func mainstoryboard() -> uistoryboard { return uistoryboard(name: "main", bundle: nsbundle.mainbundle()) } class func tabbarcontroller() -> uitabbarcontroller? { return mainstoryboard().instantiateviewcontrollerwithidentifier("tabbarcontrollerid") as? uitabbarcontroller } }
i think login view controller still in background? have logout button rightbarbutton item on each navbar in tabgroup. want able close tabbar on button press. how can achieve this. can't find examples. using pop command?
update:
@ibaction func trylogout(sender: uibarbuttonitem) { self.dismissviewcontrolleranimated(true, completion: nil) let storyboard = uistoryboard(name: "main", bundle: nil) let vc = storyboard.instantiateviewcontrollerwithidentifier("login") as! uiviewcontroller self.presentviewcontroller(vc, animated: true, completion: nil) }
Comments
Post a Comment