ios - iPhone 12 Pro 的 UIImagePickerController 的相机视图在它上面有很大的差距,其他手机没有这个差距
问题描述
我正在使用 UIImagePickerController 的相机。这是一些简化的代码来展示它
let imagePickerController = UIImagePickerController()
override func viewDidLoad() {
super.viewDidLoad()
imagePickerController.sourceType = .camera
imagePickerController.showsCameraControls = false
imagePickerController.cameraCaptureMode = .photo
// if traitCollection.horizontalSizeClass == .compact || traitCollection.verticalSizeClass == .compact {
// let screenSize = UIScreen.main.bounds.size
// let previewRatio: CGFloat = 4 / 3
// let previewHeight = screenSize.width * previewRatio
// let offset = (screenSize.height - previewHeight) / 2
// imagePickerController.cameraViewTransform = CGAffineTransform(translationX: 0, y: offset)
// }
showImagePickerController()
}
private func showImagePickerController() {
addChild(imagePickerController)
view.addSubview(imagePickerController.view)
imagePickerController.didMove(toParent: self)
}
到目前为止,在每台设备上,相机预览视图都会按预期显示在顶部:
但在 iPhone 12 Pro 上,它的顶部有很大的差距:
如果我取消注释代码中的行,则图像现在以除 iPhone 12 Pro 以外的所有 iPhone 为中心。对于该设备,它居中加上原始顶部间隙,因此低于中心。
这是Apple方面的错误吗?
解决方案
推荐阅读
- android-studio - 如何指定设备在android studio中运行应用程序
- ios - iOS 13 上下文菜单:如何通过点击预览来简单地关闭菜单?
- node.js - 尝试保存并获取文档的 ID 以将 ref 保存到另一个文档
- scala - 匿名模式匹配函数的转换
- r - 查找与其他几列相比唯一的列中的字母,分段计数并打印它们的位置
- angular - fullcalendar/resourcetimegrid 插件中的错误
- mysql - 我想将下拉值添加到mysql并保存
- c++ - 如何解决静态方法内部的 lambda 内部的歧义?
- sdk - 截止日期前无法连接
- powershell - 如何使用powershell执行sas程序