You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/10/08 16:07:07 UTC
[GitHub] [cordova-plugin-screen-orientation] oofaish commented on a diff in pull request #107: (iOS) fix(ios): add support for ios 16
oofaish commented on code in PR #107:
URL: https://github.com/apache/cordova-plugin-screen-orientation/pull/107#discussion_r990658780
##########
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:
Which version of Xcode are you using? I don’t think the latest?
--
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: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org