ios - Swift - navigation buttons show & hide -
running weird issue , couldn't find how fix it. have tab bar controller based app 3 view controllers (2 table view controllers , 1 regular vc), profile, orders, people. when sign in, land on profile , buttons in nav bar show properly. go people , come back, buttons disappear , don't show anymore. vice versa true (going people profile).
this additional weird part: if go profile orders, back, show buttons. if go profile orders people, people shows normally.
here structure:
in viewdidload , viewwillappear, add following code:
let editbutton = uibutton() editbutton.frame = cgrectmake(0, 0, 60, 35) editbutton.settitle("edit profile ", forstate: .normal) editbutton.settitlecolor(uicolor.bluecolor(), forstate: .normal) editbutton.addtarget(self, action: selector("editbuttonpressed"), forcontrolevents: .touchupinside) let leftbarbutton = uibarbuttonitem() leftbarbutton.customview = editbutton self.tabbarcontroller?.navigationitem.leftbarbuttonitem = leftbarbutton
and in viewwilldisappear, add:
self.tabbarcontroller?.navigationitem.leftbarbuttonitem = nil self.tabbarcontroller?.navigationitem.rightbarbuttonitem = nil
all except orders table view controller doesn't have of above code. going on? happy provide more if needed, there far understand.
you can try this:
1.show:
self.navigationitem.rightbarbuttonitem?.customview?.alpha = 1.0
2.hide:
self.navigationitem.rightbarbuttonitem?.customview?.alpha = 0.0
Comments
Post a Comment