oofaish commented on code in PR #107:
URL:
https://github.com/apache/cordova-plugin-screen-orientation/pull/107#discussion_r990669232
##########
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:
If you can’t bump that up to 14 then you ll have to deprecate based on Xcode
version which my code doesn’t do. I am not sure what the ups and downs of it
are and not going to have time to explore I am afraid.
--
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]