当控制器处于纵向模式时,UIImagePicker始终以横向模式打开照片应用程序,并且设备方向也是纵向 . 有人可以帮忙吗?
func actionSheet(_ actionSheet: UIActionSheet, didDismissWithButtonIndex buttonIndex: Int) {
if buttonIndex == 1 {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera) {
let controller = UIImagePickerController.init()
controller.sourceType = UIImagePickerControllerSourceType.camera
controller.delegate = self
controller.allowsEditing = true
self.present(controller, animated: true, completion: { () -> Void in
})
}
}
else if buttonIndex == 2 {
let controller = UIImagePickerController.init()
controller.sourceType = UIImagePickerControllerSourceType.photoLibrary
controller.delegate = self
controller.allowsEditing = true
self.present(controller, animated: true, completion: { () -> Void in
})
}
}
1 回答
在呈现viewcontroller之前添加此行 . 希望它能解决这个问题