在呈现和取消VNDocumentCameraViewController之后,我得到了一个黑色屏幕。经过一些研究,我发现在取消摄像机视图控制器后,一些约束消失了。
下面是VNDocumentCameraViewController之前和之后视图层次结构的比较。

我注意到的变化:
UILayoutContainerView's约束是完全的,goneRootTabBarContoller's约束是halved.”。
下面是VNDocumentCameraViewController存在时的视图层次结构。

在场景委托中初始化根视图控制器,如下所示:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else {
return
}
window = UIWindow(windowScene: windowScene)
window?.rootViewController = RootTabBarController()
window?.makeKeyAndVisible()
}我想尝试一个故事板作为最初的场景,但是我的所有视图都使用XIB,我无法找到如何将它们导入故事板。
根视图控制器(在我的例子中是RootTabBarController)是否需要额外的约束或其他配置来支持这种转换?
发布于 2022-11-10 14:08:01
因此,解决方案是相当琐碎的。由于某些原因,RootTabBarController的view.translatesAutoresizingMaskIntoConstraints = false行导致了约束问题。
删除这一行解决了这个问题。
https://stackoverflow.com/questions/74383591
复制相似问题