我已经创建了只支持横向方向的应用程序,每当我调用 UIImagePickerControllerSourceTypeCamera 以使用相机拍照时都可以,但是当我调用 UIImagePickerControllerSourceTypePhotoLibrary 时它崩溃了。
我曾尝试使用方法 shouldAutoRotate() 允许纵向但仍然无法正常工作。这个问题有什么解决办法吗?
最佳答案
当你在 iPad 上遇到这个错误时
试试下面的代码并为此目的使用 UIModalPresentationStyle :-
self.imagepicker.modalPresentationStyle = UIModalPresentationStyle.Popover
let popover = self.imagepicker.popoverPresentationController
self.imagepicker.preferredContentSize = CGSizeMake(400 ,400)
popover!.sourceView = self.view
popover!.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0)
popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.presentViewController(self.imagepicker, animated: true, completion: nil)
这是在 Swift 中,我希望你能轻松地转换到 objective-c。
希望对您有所帮助。
关于当方向只允许横向时,iOS 9 UIImagePickerControllerSourceTypePhotoLibrary 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40017906/