marco-hd commented on PR #107:
URL:
https://github.com/apache/cordova-plugin-screen-orientation/pull/107#issuecomment-1323432579
**iPhone XR / iOS 16.1.1 / XCode 14.1**
Hi guys,
I can confirm:
- rotation is working
- double rotation is fixed
However, the unlocking doesn't happen anymore.
I have no experience with Obj-C (please bear with me), but I tried to make
it work this way:
```
...
if (_lastOrientation != UIInterfaceOrientationUnknown) {
((void (*)(CDVViewController*, SEL,
NSMutableArray*))objc_msgSend)(vc,selector,result);
if (@available(iOS 16.0, *)) {
[self.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
value16 = [[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:_lastOrientation];
}
else {
[[UIDevice currentDevice] setValue:[NSNumber
numberWithInt:_lastOrientation] forKey:@"orientation"];
[UINavigationController attemptRotationToDeviceOrientation];
}
}
...
```
and the _lastOrientation initialisation:
```
...
if (!_isLocked) {
if (@available(iOS 16.0, *)) {
UIWindowScene *scene =
(UIWindowScene*)[[UIApplication.sharedApplication connectedScenes] anyObject];
switch(scene.interfaceOrientation) {
case UIInterfaceOrientationUnknown:
_lastOrientation = UIInterfaceOrientationMaskAll;
break;
case UIInterfaceOrientationPortrait:
_lastOrientation = UIInterfaceOrientationMaskPortrait;
break;
case UIInterfaceOrientationPortraitUpsideDown:
_lastOrientation =
UIInterfaceOrientationMaskPortraitUpsideDown;
break;
case UIInterfaceOrientationLandscapeLeft:
_lastOrientation = UIInterfaceOrientationMaskLandscapeLeft;
break;
case UIInterfaceOrientationLandscapeRight:
_lastOrientation =
UIInterfaceOrientationMaskLandscapeRight;
break;
}
} else {
_lastOrientation = [UIApplication
sharedApplication].statusBarOrientation;
}
}
...
```
So, it kind of works, but the locked screen can be unlocked by pure rotation
of the device.
Any idea how to keep it locked until it is explicitly unlocked from the JS
WebView world?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]