I'm using UIImagePickerController inside a UIPopoverController to select image just from photo albums. When I launch app on device running iOS 8, the Cancel button on the top right of the pop over appeared normally like this:
But when I launch the app on device running iOS 7, the Cancel button disappeared:
The code I used to show the picker:
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];
What can I do to show that Cancel button on iOS7? My app design doesn't allow user to dismiss the popover by tapping anywhere outside the popover view.
Thank you.
In my case,
UIImagePickerController
was not showing its cancel button . So I tried adding this line to code:And this worked for me.Try setting color of Cancel button like this
Try using this code and let me know if it helps you.
@JozoL Write the Below Code this works
For swift2.x you can try below code, Its work for me
pickerController.navigationBar.tintColor = UIColor.blueColor()