美文网首页
ios16 旋转屏幕

ios16 旋转屏幕

作者: 九月_adhoc | 来源:发表于2024-01-03 12:54 被阅读0次
      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 屏幕旋转

    iOS16 强行让屏幕旋转 UIDevice.current.setValue(UIInterfaceOrient...

  • iOS16屏幕旋转

    iOS16出来一段时间了,个别app出现屏幕不能强制旋转全屏,原因就是iOS不再支持UIDevice 方式的旋转下...

  • iOS16适配-屏幕旋转

    声明:本文适配以iOS 16 bate 2为基准 背景 iOS 16在UIKIT上有了一些更改,废弃掉了一些修改方...

  • iOS16适配 屏幕旋转横屏

    背景 iOS16之前转屏方法, 16之后无效, 导致界面错乱.虽然Xcode14/iOS16提供了新的api但还是...

  • iOS 屏幕旋转

    屏幕旋转 认知 期望达到的目的 如何让App支持屏幕旋转 如何让App屏幕旋转 如何保证屏幕旋转后布局不会乱 总结...

  • 屏幕旋转

    屏幕旋转 推荐文档 了解UIWindow——UIWindow实践 iOS屏幕旋转问题总结 IOS:屏幕旋转与变换 ...

  • 屏幕旋转

    UIDevice.current.setValue(UIInterfaceOrientation.landscap...

  • 屏幕旋转

    import "AppDelegate.h" import "ViewController.h" @interfa...

  • 屏幕旋转

    在做工程的时候碰到了屏幕旋转的问题,如今已经解决.为大家分享一下 屏幕旋转机制流程 (1)加速计检测到方向变化,发...

  • 屏幕旋转

    每个视图控制器都控制着自己的旋转方向,如果需要新的旋转权限需要模态出新的视图控制器(如navigation tab...

网友评论

      本文标题:ios16 旋转屏幕

      本文链接:https://www.haomeiwen.com/subject/kvomndtx.html