Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hiepit127 opened this issue Jul 25, 2024 · 0 comments
Open

Comments

@hiepit127
Copy link

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()
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant