webfletch commented on code in PR #107:
URL:
https://github.com/apache/cordova-plugin-screen-orientation/pull/107#discussion_r990669762
##########
src/ios/CDVOrientation.m:
##########
@@ -56,31 +56,64 @@ -(void)screenOrientation:(CDVInvokedUrlCommand *)command
}
if ([UIDevice currentDevice] != nil){
- NSNumber *value = nil;
+ NSValue *value;
+ NSObject *value16;
if (orientationMask != 15) {
if (!_isLocked) {
_lastOrientation = [UIApplication
sharedApplication].statusBarOrientation;
}
UIInterfaceOrientation deviceOrientation = [UIApplication
sharedApplication].statusBarOrientation;
if(orientationMask == 8 || (orientationMask == 12 &&
!UIInterfaceOrientationIsLandscape(deviceOrientation))) {
- value = [NSNumber
numberWithInt:UIInterfaceOrientationLandscapeLeft];
+ if (@available(iOS 16.0, *)) {
+ value16 = [[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:UIInterfaceOrientationMaskLandscapeLeft];
+ } else {
+ value = [NSNumber
numberWithInt:UIInterfaceOrientationLandscapeLeft];
+ }
} else if (orientationMask == 4){
- value = [NSNumber
numberWithInt:UIInterfaceOrientationLandscapeRight];
+ if (@available(iOS 16.0, *)) {
+ value16 = [[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:UIInterfaceOrientationMaskLandscapeRight];
+ } else {
+ value = [NSNumber
numberWithInt:UIInterfaceOrientationLandscapeRight];
+ }
} else if (orientationMask == 1 || (orientationMask == 3 &&
!UIInterfaceOrientationIsPortrait(deviceOrientation))) {
- value = [NSNumber
numberWithInt:UIInterfaceOrientationPortrait];
+ if (@available(iOS 16.0, *)) {
+ value16 = [[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:UIInterfaceOrientationMaskPortrait];
+ } else {
+ value = [NSNumber
numberWithInt:UIInterfaceOrientationPortrait];
+ }
} else if (orientationMask == 2) {
- value = [NSNumber
numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
+ if (@available(iOS 16.0, *)) {
+ value16 = [[UIWindowSceneGeometryPreferencesIOS alloc]
initWithInterfaceOrientations:UIInterfaceOrientationMaskPortraitUpsideDown];
+ } else {
+ value = [NSNumber
numberWithInt:UIInterfaceOrientationPortraitUpsideDown];
+ }
}
} else {
if (_lastOrientation != UIInterfaceOrientationUnknown) {
[[UIDevice currentDevice] setValue:[NSNumber
numberWithInt:_lastOrientation] forKey:@"orientation"];
((void (*)(CDVViewController*, SEL,
NSMutableArray*))objc_msgSend)(vc,selector,result);
- [UINavigationController
attemptRotationToDeviceOrientation];
+ if (@available(iOS 16.0, *)) {
+ [self.viewController
setNeedsUpdateOfSupportedInterfaceOrientations];
+ }
+ else {
+ [UINavigationController
attemptRotationToDeviceOrientation];
+ }
+
+ // [UINavigationController
attemptRotationToDeviceOrientation];
}
}
- if (value != nil) {
+ if (value != nil || value16 != nil) {
_isLocked = true;
- [[UIDevice currentDevice] setValue:value
forKey:@"orientation"];
Review Comment:
No problem, I have got in touch with Ionic to ask when they will be adding
Xcode 14, in the meantime I am adding an option for the user to be able to
disable the screen rotation functionality as a setting in the App to stop
people on iOS 16 from getting stuck in landscape mode when the app is generally
supposed to run in portrait mode.
--
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]