swift - 使用 UIViewControllerRepresentable 的 VNDocumentCameraViewController 的安全区域问题

标签 swift swiftui uikit uiviewcontrollerrepresentable vndocumentcameraviewcontroller

在 UIViewControllerRepresentable 中使用 VNDocumentCameraViewController 时,如何将相机扫描 View 扩展到 safa 区域?

这是代码

struct ScanDocumentView: UIViewControllerRepresentable {
    
    func makeCoordinator() -> Coordinator {
        Coordinator(recognizedText: $recognizedText, parent: self)
    }
    
    func makeUIViewController(context: Context) -> VNDocumentCameraViewController {
        let documentViewController = VNDocumentCameraViewController()
        documentViewController.delegate = context.coordinator
        return documentViewController
    }
    
    func updateUIViewController(_ uiViewController: VNDocumentCameraViewController, context: Context) {
        // nothing to do here
    }
}

这是底部安全区域为空白的行为 behavior

最佳答案

问题解决了!只需添加

.ignoresSafeArea()

ScanDocumentView()

仅此而已

关于swift - 使用 UIViewControllerRepresentable 的 VNDocumentCameraViewController 的安全区域问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65750820/

相关文章:

colors - SwiftUI:使用 Assets 目录中的颜色集

ios - 有没有办法在 SwiftUI 中创建新的手势?

ios - JSON 解析错误 Swift 3

ios - 尝试将平移手势应用于 UITableViewCell 但失败了,为什么?

ios - 在 iOS 应用程序中使用 HeroIcons 时模糊的 SVG 渲染

ios - 按钮构造函数似乎不允许局部变量

ios - 检测何时 requestAlwaysAuthorization 未调用 iOS 14

swift - 如何使用 stateobject 作为参数初始化 View ?

ios - 模态关闭后,键盘显示错误的颜色 - iOS

ios - CGAffineTransformScale 在使用 UIDynamicAnimator 时不发送它的比例