每当我尝试在我的控制器上只允许纵向方向时,我总是收到这个错误:
错误域=UISceneErrorDomain 代码=101 "视图控制器不支持任何请求的方向。请求的方向:landscapeLeft;支持的方向:portrait" 用户信息={NSLocalizedDescription=视图控制器不支持任何请求的方向。请求的方向:landscapeLeft;支持的方向:portrait}
我调用了这个方法:
有人遇到过同样的问题吗?
我调用了这个方法:
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 )
}
}
}
}
有人遇到过同样的问题吗?