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

问题描述 投票:2回答:3

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

在iPad中,一条错误消息提示您使用了弹出框,但我无法在全屏模式下显示图像选择器。有可能吗?

有人告诉我可以使用presentModalViewController完成。如果是这样,谁能指出我的教程?

ipad uiimagepickercontroller modalviewcontroller
3个回答
4
投票

有可能!

只需删除此:

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

并改用它:

[self presentModalViewController:picker animated:YES];

选择器是您的UIImagePickerController。


0
投票

不可能。仅弹出窗口可用于执行此操作,无法全屏显示。


0
投票

Swift:可以通过更改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)
}
© www.soinside.com 2019 - 2024. All rights reserved.