react-native-orientation-locker icon indicating copy to clipboard operation
react-native-orientation-locker copied to clipboard

fix ios 16 Setting UIDevice.orientation

Open ceddybi opened this issue 1 year ago • 18 comments

BUG IN CLIENT OF UIKIT: Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:)

Source

#241

PS: Works on my end now, please update if you have any suggestions.

ceddybi avatar Sep 30 '22 03:09 ceddybi

@ceddybi In my case, this change does not help, the screen orientation changes if I turn the phone.

Shabanisimo avatar Sep 30 '22 14:09 Shabanisimo

This addresses the iOS 16 issue in our project, thanks for the fix!

jfspencerAngel avatar Oct 01 '22 04:10 jfspencerAngel

@jfspencerAngel @ceddybi Before iOS 16, device orientation change notifies when locktolandscape or portrait but it is not working now(iOS 16) until rotate the device. something to do with setNeedsUpdateOfSupportedInterfaceOrientations ? https://developer.apple.com/documentation/uikit/uiviewcontroller/4047535-setneedsupdateofsupportedinterfa?language=objc

venky145 avatar Oct 02 '22 12:10 venky145

@ceddybi Thank you for your PR I suggest to apply below code, because UIDeviceOrientationDidChangeNotification couldn't detect orientation change when orientation changed via lockTo** method.

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
        [self addListener:@"orientationDidChange"];

I know UIApplicationWillChangeStatusBarOrientationNotification is deprecated from iOS13 but this library already used deprecated API like UIApplication.statusBarOrientation, so I just suggest it. unfortunately I'm not a specialist of iOS dev🥲, If you know any alternative solution, I hope you feel free to use that

YangJonghun avatar Oct 06 '22 18:10 YangJonghun

useEffect(() => { Orientation.addLockListener(onOrientationDidChange); // ios16 can full screen when orientation lanspage // Orientation.addOrientationListener(onOrientationDidChange); // ios16 not full screen , only 1/2 screen

    return (() => {
        Orientation.removeOrientationListener(onOrientationDidChange);
    })
}, [])

nguyenhuynhdeveloper avatar Oct 21 '22 04:10 nguyenhuynhdeveloper