是否可以在iPad中全屏显示UIImagePickerController?

时间:2011-06-20 20:11:34

标签: ipad uiimagepickercontroller modalviewcontroller

我目前正在开发应用程序的iPad版本,我使用UIImagePickerController让用户从他们的库中选择一张照片。

在iPad中,错误消息显示使用弹出式窗口,但我无法在全屏显示我的图像拾取器。有可能吗?

我被告知可以使用presentModalViewController完成。如果是这样,任何人都可以指点我的教程吗?

3 个答案:

答案 0 :(得分:4)

有可能!

只需删除它:

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popoverController presentPopoverFromRect:frame
                                   inView:self.view
                 permittedArrowDirections:UIPopoverArrowDirectionAny
                                 animated:YES];

然后使用它:

[self presentModalViewController:picker animated:YES];

选择器是你的UIImagePickerController。

答案 1 :(得分:0)

不可能。只有Popovers可以用来做,全屏是不可能的。

答案 2 :(得分:0)

迅速:可以通过更改modalPresentationStyle来实现。

@IBAction func openPhotoLibrary(_sender:UIButton){
  if !UIImagePickerController.isSourceTypeAvailable(UIImagePickerController.SourceType.photoLibrary){return}

  let imagePicker = UIImagePickerController()
  imagePicker.sourceType = UIImagePickerController.SourceType.photoLibrary
  imagePicker.allowsEditing = false
  imagePicker.delegate = self
  imagePicker.modalPresentationStyle = .overCurrentContext

  self.present(imagePicker, animated: true, completion: nil)
}