UIPopoverController中的UIImagePickerController不显示iOS7上的取消button

我使用UIPopoverController中的UIImagePickerController从相册中select图像。 当我在运行iOS 8的设备上启动应用程序时,popup窗口右上angular的“取消”button正常显示如下:

在这里输入图像说明

但是,当我在运行iOS 7的设备上启动应用程序时,“取消”button消失: 在这里输入图像说明

我用来显示select器的代码:

UIImagePickerController *pickerController = [[UIImagePickerController alloc] init]; [pickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; pickerController.delegate = self; _popOver = [[UIPopoverController alloc] initWithContentViewController:pickerController]; _popOver.delegate = self; pickerController.navigationBar.tintColor = [UIColor redColor];//Cancel button text color [pickerController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]}];// title color if (isImage) { [pickerController setMediaTypes:@[(NSString*)kUTTypeImage]]; } else [pickerController setMediaTypes:@[(NSString*)kUTTypeMovie]]; [_popOver presentPopoverFromRect:CGRectMake(1024/2, 768/2, 1, 1) inView:self.view permittedArrowDirections:0 animated:YES]; 

我能做些什么来显示iOS7上的取消button? 我的应用程序devise不允许用户通过点击popup视图外的任何地方来closurespopup窗口。

谢谢。

@JozoL写下面的代码这个作品

 - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { UINavigationItem *pickerNavBarTopItem; // add done button to right side of nav bar UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(doSomething)]; UINavigationBar *bar = navigationController.navigationBar; [bar setHidden:NO]; pickerNavBarTopItem = bar.topItem; pickerNavBarTopItem.rightBarButtonItem = doneButton; } -(void)doSomething{ } 

在我的情况下, UIImagePickerController没有显示其取消button。 所以我尝试添加这一行代码:

 pickerController.navigationBar.barStyle = UIBarStyleDefault; 

这对我有用。尝试像这样设置取消button的颜色

  pickerController.navigationBar.tintColor = [UIColor blackColor]; 

尝试使用此代码,并让我知道,如果它可以帮助你。

对于swift2.x,你可以尝试下面的代码,它为我工作

pickerController.navigationBar.tintColor = UIColor.blueColor()