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)
}
精彩评论