我正在尝试更改UIImagePickerController的导航栏按钮。到目前为止,我只设法更改了右侧栏按钮项(“取消”按钮):
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
UINavigationBar *bar = navigationController.navigationBar;
UINavigationItem *top = bar.topItem;
top.title = @"Photos";
UIImage *buttonImageCancel = [UIImage imageNamed:@"DoneBarButton.png"];
UIButton *buttonCancel = [[UIButton alloc] initWithFrame:CGRectMake(0,5,55, 29)];
[buttonCancel setBackgroundImage:buttonImageCancel forState:UIControlStateNormal];
[buttonCancel addTarget:self action:@selector(imagePickerControllerDidCancel:) forControlEvents:UIControlEventTouchUpInside];
[buttonCancel setTitle:@"Cancel" forState:UIControlStateNormal];
[buttonCancel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[[buttonCancel titleLabel] setFont:[UIFont boldSystemFontOfSize:10]];
UIBarButtonItem *barButtonCancel = [[UIBarButtonItem alloc] initWithCustomView:buttonCancel];
[top setRightBarButtonItem:barButtonCancel]; }
但是在其他视图控制器(例如“照片库”)中,“取消”按钮再次是旧的。此外,在切换回主选择器视图后,定制的“取消”按钮再次被标准的替换。 有谁知道如何更改这些按钮?子类? 非常感谢!
答案 0 :(得分:1)
只有在推送视图控制器时才会调用您实现的方法。如果您想在整个选择器中进行更改,则可以使用导航控制器类别。