ios - Open UIImagePickerController in landscape in Swift 3 -
i trying present uiimagepickercontroller
in landscape mode iphone 7
, iphone se
(iphone 7 plus , ipad use popover). create sub class of uiimagepickercontroller :
class landscapeuiimagepickercontroller: uiimagepickercontroller { override var supportedinterfaceorientations: uiinterfaceorientationmask { return .landscape } override var shouldautorotate: bool { return true } override var preferredinterfaceorientationforpresentation: uiinterfaceorientation { return .landscaperight }
and call :
func importfromgallery(_ sender:uibutton) { let imagepicker = landscapeuiimagepickercontroller() imagepicker.modalpresentationstyle = .popover imagepicker.popoverpresentationcontroller?.sourceview = sender imagepicker.popoverpresentationcontroller?.sourcerect = sender.bounds imagepicker.popoverpresentationcontroller?.permittedarrowdirections = .down imagepicker.delegate = self present(imagepicker, animated: true, completion: nil) }
this custom class works when check portrait
option in device orientation :
but don't want check option because affects other parts of app keyboard's accessory view , input view. there possible way open uiimagepickercontroller without checking option ? unchecked portrait , app crashes error :
* terminating app due uncaught exception 'uiapplicationinvalidinterfaceorientation', reason: 'supported orientations has no common orientation application, , [puuialbumlistviewcontroller shouldautorotate] returning yes' * first throw call stack:
i fine if image picker opens in portrait have disable portrait option.
Comments
Post a Comment