iphone - segmentedcontrol in navigationbar -
i trying put in navigationbar, doesnt show up, can u have @ it?
uisegmentedcontrol *seg1 = [[uisegmentedcontrol alloc] initwithitems:[nsarray arraywithobjects:@"von mir", @"alle", nil]]; [seg1 setsegmentedcontrolstyle:uisegmentedcontrolstylebar]; uibarbuttonitem *baritem = [[uibarbuttonitem alloc] initwithcustomview:seg1]; uibarbuttonitem *flexitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:self action:nil]; [self.navigationcontroller.navigationbar setitems:[nsarray arraywithobjects:flexitem, baritem, flexitem, nil]]; [flexitem release]; [baritem release]; [seg1 release];
uinavigationbar
's items
property accepts array of uinavigationitem
objects, not uibarbuttonitem
objects. can't configure navigation bar same way uitoolbar
. instead, in view controller, this:
uisegmentedcontrol * seg1 = [[uisegmentedcontrol alloc] initwithitems:[nsarray arraywithobjects:@"von mir", @"alle", nil]]; [seg1 setsegmentedcontrolstyle:uisegmentedcontrolstylebar]; self.navigationitem.titleview = seg1;
this adds segmented control title view of view controller's navigation item, custom view appears centered on navigation bar.
Comments
Post a Comment