AppDelegateProvider.shared.delegate?.setLandscapeRight(true)
if #unavailable(iOS 16) {
let value = UIInterfaceOrientation.landscapeRight.rawValue
if UIDevice.current.responds(to: #selector(setValue(_:forKey:))) {
// 及时更新旋转的方向,如果不更新,可能造成旋转失败
_ = AppDelegateProvider.shared.delegate?.applicationInApp(UIApplication.shared, supportedInterfaceOrientationsFor: UIApplication.shared.keyWindow)
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
}
}else{
// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
// _ = AppDelegateProvider.shared.delegate?.applicationInApp(UIApplication.shared, supportedInterfaceOrientationsFor: UIApplication.shared.keyWindow)
// UIApplication.shared.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
//// navController.setNeedsUpdateOfSupportedInterfaceOrientations()
// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: .landscapeRight)) { error in
// print(error)
// print(windowScene?.effectiveGeometry ?? "")
// }
}
UIApplication.shared.keyWindow?.rootViewController!.present(navController, animated: animated, completion: nil)
// if #available(iOS 16, *) {
// let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
// _ = AppDelegateProvider.shared.delegate?.applicationInApp(UIApplication.shared, supportedInterfaceOrientationsFor: UIApplication.shared.keyWindow)
// UIApplication.shared.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()
// navController.setNeedsUpdateOfSupportedInterfaceOrientations()
// windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: .landscapeRight)) { error in
// print(error)
// print(windowScene?.effectiveGeometry ?? "")
// }
// }
ios16 旋转屏幕
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 声明:本文适配以iOS 16 bate 2为基准 背景 iOS 16在UIKIT上有了一些更改,废弃掉了一些修改方...
- 2021年,iOS 15发布10天后,有19.3%的设备安装了iOS 15;今年iPhone用户采用iOS 16的...