开发者

Is it possible to show a UIImagePickerController at full screen in iPad?

开发者 https://www.devze.com 2023-03-14 17:12 出处:网络
I\'m currently working on the iPad version of an app, where I used UIImagePickerController t开发者_如何学JAVAo let the user pick a photo from their library.

I'm currently working on the iPad version of an app, where I used UIImagePickerController t开发者_如何学JAVAo let the user pick a photo from their library.

In the iPad an error message suggests using a popover, but I can't show my imagepicker at fullscreen. Is it possible?

I'm being told that it can be done using presentModalViewController. If so can anyone point me to a tutorial?


It is possible!

Just remove this:

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

And use this instead:

[self presentModalViewController:picker animated:YES];

Where picker is your UIImagePickerController.


Not possible. Only Popovers can be used to do it, full screen is not possible.


Swift: It is possible by changing 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)
}
0

精彩评论

暂无评论...
验证码 换一张
取 消