UIImagePicker 始终以横向模式打开照片应用程序
UIImagePicker opens Photos app in Landscape Mode always
当控制器处于纵向模式时,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
})
}
}
在呈现之前添加此行 viewcontroller。希望它能解决问题
controller.modalPresentationStyle = .overCurrentContext
当控制器处于纵向模式时,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
})
}
}
在呈现之前添加此行 viewcontroller。希望它能解决问题
controller.modalPresentationStyle = .overCurrentContext