ios - How to make UIViewController pop Swift SWRevealViewController -
so have app, has profile page have mainview in storyboard, tableview , profile view when go profile view want able go mainview try this
class profileviewcontroller: uiviewcontroller, uitextfielddelegate, uinavigationbardelegate{ var bar: uinavigationbar! override func viewdidload(){ super.viewdidload() self.view.addgesturerecognizer(self.revealviewcontroller().pangesturerecognizer()) bar = createbar(); } func createbar() -> uinavigationbar{ let bar = uinavigationbar(frame: cgrectmake(0,0,self.view.frame.size.width,60)) bar.bartintcolor = uicolor(red: 26/255, green: 53/255, blue: 72/255, alpha: 1.0) bar.delegate = self let navigationitem = uinavigationitem() navigationitem.title = "profile" let leftbutton = uibarbuttonitem(title: "back", style: uibarbuttonitemstyle.plain, target: self, action: "goback:") let rightbutton = uibarbuttonitem(title: "edit", style: uibarbuttonitemstyle.plain,target: self, action: nil) leftbutton.tintcolor = uicolor.whitecolor() rightbutton.tintcolor = uicolor.whitecolor() //bar.tittletextattributes = [uitextattributetextcolor: uicolor.whitecolor()] navigationitem.leftbarbuttonitem = leftbutton navigationitem.rightbarbuttonitem = rightbutton bar.items = [navigationitem] self.view.addsubview(bar) return bar; } func goback(sender: uibarbuttonitem!){ if let navcontroller = self.navigationcontroller{ navcontroller.popviewcontrolleranimated(true) } } }
i'm working on 2 hours , can't solve it, can help? forgot mention i'm using swrevealviewcontroller
embed reveal view controller in uinavigationcontroller.
right now, backtable view controller , profileview controller not in navigation controller's hierarchy. also, segues should push segues work. don't use modal segues.
follow simple tutorial more clarity: http://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-navigation-controllers-and-view-controller-hierarchies--cms-25462
Comments
Post a Comment