小编Hat*_*ine的帖子

iOS 16 场景方向问题

当我尝试在控制器上仅允许纵向方向时,我总是收到此错误:Error Domain=UISceneErrorDomain Code=101“视图控制器不支持所请求的方向。请求:landscapeLeft;支持:纵向”UserInfo={NSLocalizedDescription=视图控制器不支持所请求的方向。请求:景观左;支持:纵向}

我称这个方法为:

func updateOrientation(orientation: UIInterfaceOrientationMask) {
        if #available(iOS 16, *) {
            DispatchQueue.main.async {
                let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
                self.setNeedsUpdateOfSupportedInterfaceOrientations()
                self.navigationController?.setNeedsUpdateOfSupportedInterfaceOrientations()
                windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation)) { error in
                    print(error)
                    print(windowScene?.effectiveGeometry )
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

有人面临同样的问题吗?

portrait orientation ios16 xcode14

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

ios16 ×1

orientation ×1

portrait ×1

xcode14 ×1