ios - UINavigationItem - no "free" backbutton for one of my buttons -
so in main window have these 2 buttons "settings"(leftbarbuttonitem) & "i"(info button,rightbarbuttonitem)"
when press info button "free" button, have create 1 programmatically settings button? why that?
here how programmed buttons in viewdidload
uibarbuttonitem *settingsbarbuttonitem =[[uibarbuttonitem alloc]initwithtitle:@"settings" style:uibarbuttonitemstylebordered target:self action:@selector(settings:)]; self.navigationitem.leftbarbuttonitem = settingsbarbuttonitem; uibutton* infobutton = [uibutton buttonwithtype:uibuttontypeinfolight]; cgrect frame = infobutton.frame; frame.size.width = 40.0f; infobutton.frame = frame; [infobutton addtarget:self action:@selector(about:) forcontrolevents:uicontroleventtouchupinside]; butinfo = [[uibarbuttonitem alloc] initwithcustomview:infobutton]; self.navigationitem.rightbarbuttonitem = butinfo;
how viewcontroller invoked? in general "free" button happens if view controller pushed onto navigation stack parent viewcontroller. via segue (if using storyboard), or via - (void)pushviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated (message uinavigationcontroller).
from uinavigationcontroller documentation: if top-level view controller not have custom left bar button item, navigation item of previous view controller has valid item in backbarbuttonitem property, navigation bar displays item.
if custom bar button item not specified either of view controllers, default button used , title set value of title property of previous view controller—that is, view controller 1 level down on stack. (if there 1 view controller on navigation stack, no button displayed.)
this means must have set title property of parent view controller display button it's name.
Comments
Post a Comment