gpt4 book ai didi

ios - UIImagePicker 始终以横向模式打开照片应用程序

转载 作者:行者123 更新时间:2023-11-29 00:09:51 26 4
gpt4 key购买 nike

当 Controller 处于纵向模式时,UIImagePicker 始终以横向模式打开照片应用程序,并且设备方向也是纵向。有人可以帮忙吗?

enter image description here

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

})
}
}

最佳答案

在呈现 View Controller 之前添加此行。希望能解决问题

controller.modalPresentationStyle = .overCurrentContext

关于ios - UIImagePicker 始终以横向模式打开照片应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46807452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com