UIImagePickerController
在相册中选择图片时,推出图片选择的控制器时,状态会变为默认颜色。点取消返回后却没有变回去。
如果不想改变颜色,可以用下面的方法:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
UIImagePickerController是继承至UINavigationController。如果其他地方的UINavigationController用的UINavigationController的子类,并且自定义了返回按钮。在UIImagePickerController中的返回按钮不会改变,可以用下面的方法:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
_imageNavigationController = navigationController;
if (viewController.navigationItem.leftBarButtonItem == nil && [navigationController.viewControllers count] > 1) {
viewController.navigationItem.leftBarButtonItem =[self createBackButton:navigationController];
}
}
-(UIBarButtonItem*)createBackButton:(UINavigationController *)navigationController
{
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStyleBordered target:self action:@selector(popViewController)];
return barButtonItem;
}
-(void)popViewController
{
[_imageNavigationController popViewControllerAnimated:YES];
}