【发布时间】:2014-11-14 03:35:23
【问题描述】:
我在 UIPopoverController 中使用 UIImagePickerController 仅从相册中选择图像。当我在运行 iOS 8 的设备上启动应用程序时,弹出窗口右上角的取消按钮通常如下所示:
但是当我在运行 iOS 7 的设备上启动应用程序时,取消按钮消失了:
我用来显示选择器的代码:
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 上显示取消按钮?我的应用设计不允许用户通过点击弹出框视图之外的任何位置来关闭弹出框。
谢谢。
【问题讨论】:
-
你能告诉我相关的代码吗?
-
iOS8默认出现取消按钮
-
@SureshToutam 是的。但是我也可以在 iOS7 上展示它吗?
-
您不需要取消按钮。用户只需在弹出框外点击即可将其关闭。
-
@rmaddy 是的,我知道。但我的应用设计不允许用户以通常的方式关闭弹出框。
标签: ios ios7 ios8 uiimagepickercontroller uipopovercontroller