Skip to content

Screen rotation lock feature doesn't work on devices older than iOS 16. #111

Description

@hiepit127

Do your libraries interfere with the device's screen rotation? The screen rotation lock feature works well, but when adding FURenderKit, it doesn't work on devices older than iOS 16.

Hear is my code

    public static func lockToOrientation(newOrientation: UIInterfaceOrientation, using mask: UIInterfaceOrientationMask) {
        instance.orientationMark = mask
        if #available(iOS 16.0, *) {
            if let windowScence = instance.getWindowScence() {
                let windowScenceGeometry = UIWindowScene.GeometryPreferences.iOS(interfaceOrientations: mask)
                windowScence.requestGeometryUpdate(windowScenceGeometry) { error in
                    print("Update Geometry error : \(error.localizedDescription)")
                }
            }
        } else {
            UIDevice.current.setValue(UIInterfaceOrientation.unknown.rawValue, forKey: "orientation")
            UIDevice.current.setValue(newOrientation.rawValue, forKey: "orientation")
            FURenderer.setDeviceOrientation(Int32(mask.toFUImageOrientation.rawValue))
        }
        UIViewController.attemptRotationToDeviceOrientation()
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions