my question simple: how can change change title of bar button in uiimagepickercontroller's navigation bar? created controller uiimagepickercontroller (triggered pressure onto button) , tried modify properties:
- (ibaction)choosefromroll:(id)sender { if ([uiimagepickercontroller issourcetypeavailable: uiimagepickercontrollersourcetypesavedphotosalbum]){ uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc] init]; imagepicker.navigationbar.tintcolor = [uicolor colorwithred:0.42 green:0.18 blue:0.66 alpha:1.0]; //imagepicker.navigationitem.title = @"scegli foto profilo"; imagepicker.delegate = self; imagepicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; imagepicker.mediatypes = [nsarray arraywithobjects: (nsstring *) kuttypeimage, nil]; imagepicker.allowsediting = no; [imagepicker.navigationcontroller.navigationitem.rightbarbuttonitem settitle:@"annulla"]; [self presentviewcontroller:imagepicker animated:yes completion:nil]; } }
but nothing changed, navigation bar correctly modified.
here's code function willshowviewcontroller:
- (void) navigationcontroller:(uinavigationcontroller *)navigationcontroller willshowviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated{ uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 320, 30)]; label.textalignment = 2; label.frame = cgrectmake(label.frame.origin.x, label.frame.origin.y, label.frame.size.width-200,label.frame.size.height); label.adjustsfontsizetofitwidth = yes; label.font = [uifont fontwithname:@"futura" size:15.0]; [label setfont:[uifont boldsystemfontofsize:16.0]]; [label setbackgroundcolor:[uicolor clearcolor]]; [label settextcolor:[uicolor whitecolor]]; [label settext:@"scegli foto profilo"]; [navigationcontroller.navigationbar.topitem settitleview:label.viewforbaselinelayout]; [navigationcontroller.navigationbar.topitem.rightbarbuttonitem settitle:@"annulla"]; }
can tell me where's mistake?
thanks
here code snippet twicking title of navigation bar in uiimage picker.
- (void)navigationcontroller:(uinavigationcontroller *)navigationcontroller willshowviewcontroller:(uiviewcontroller *)viewcontroller animated:(bool)animated { uinavigationitem *ipcnavbartopitem; // add done button right side of nav bar uibarbuttonitem *donebutton = [[uibarbuttonitem alloc] initwithtitle:@"photos" style:uibarbuttonitemstyleplain target:self action:@selector(saveimages:)]; uinavigationbar *bar = navigationcontroller.navigationbar; [bar sethidden:no]; ipcnavbartopitem = bar.topitem; ipcnavbartopitem.title = @"photos"; ipcnavbartopitem.rightbarbuttonitem = donebutton; }
hope out.
edit:
the answer first question yes can use ibaction or use method provided above create button, both should work. if using inaction, make sure declare controller within can make appear , dismiss within action method. answer second question if want change title of view presented when image picker photo album presented need create new subview , pop allow user select desired image can change title way did above. lengthy process, not recommend it. answer third question, try using following code snippet declare button,
[btn.titlelabel setfont:[uifont boldsystemfontofsize:13]];
where btn name of button , can modify font name , size. hope answers can you. luck , let me know if need more help.
Comments
Post a Comment