Closed msmtamburro closed 1 year ago
Specific guidance: https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-16-release-notes
[UIViewController shouldAutorotate] has been deprecated is no longer supported. [UIViewController attemptRotationToDeviceOrientation] has been deprecated and replaced with [UIViewController setNeedsUpdateOfSupportedInterfaceOrientations].
Workaround: Apps relying on shouldAutorotate should reflect their preferences using the view controllers supportedInterfaceOrientations. If the supported orientations change, use `-[UIViewController setNeedsUpdateOfSupportedInterface
Replacing line 78 with something like this might work (untested):
if (@available(iOS 16.0, *)) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_15_5 // Xcode 14 and iOS 16, or greater
[self.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
#endif
} else {
[UINavigationController attemptRotationToDeviceOrientation];
}
Hello there!
i've tried replacing
[UINavigationController attemptRotationToDeviceOrientation]
with your code. Unfortunately when i force the orientationChange, it doesn't trigger. Meanwhile i cannot find any indication or clear example to use requestGeometryUpdate
Upvoting that suggested change did not work for us either.
Apologies that I still haven't had time to play with this. For diagnostics: When you're trying to use setNeedsUpdateOfSupportedInterfaceOrientations
from Xcode 14 RC on iOS 16, does your list of supported orientations only include the desired orientation?
Hi, the fix is working, but you have to replace line 83 [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
with your code
@Robertndrei ok, i've replaced every
[UIDevice currentDevice] setValue:value forKey:@"orientation"]
and
[UINavigationController attemptRotationToDeviceOrientation]
with
if (@available(iOS 16.0, *)) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_15_5 // Xcode 14 and iOS 16, or greater
[self.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
#endif
} else {
[UINavigationController attemptRotationToDeviceOrientation];
}
and now seems work correctly
@tookiez's fix (replacing lines 78 and 83 with the suggestion from above) worked for me too. How can we help get this fix released?
Actually only line 83 is necessary to be replaced
Thanks for tracing this down, everyone!
I added a PR, but since the last update on this library was 2019, I have a feeling no PR will be merged in the near future: https://github.com/apache/cordova-plugin-screen-orientation/pull/102
In the meantime, I created a repo with the fix: https://github.com/521dimensions/cordova-plugin-screen-orientation
You can use it with:
cordova plugin add git+ssh://git@github.com:521dimensions/cordova-plugin-screen-orientation.git
Hope this helps someone else!
@jaydrogers i tested your fork on a Simulator with a iPhone X on iOS 12.4 Compiled on XCode 14. Add the moment screen orientation does not lock in any directions
Strange!
If you find issues, chime in on this PR. Looks like a contributor is looking at it now: https://github.com/apache/cordova-plugin-screen-orientation/pull/102
if use xcode 13,the following is better:
if (@available(iOS 16.0, *)) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_15_5
SEL supportedInterfaceSelector = NSSelectorFromString(@"setNeedsUpdateOfSupportedInterfaceOrientations");
[self.viewController performSelector:supportedInterfaceSelector];
#endif
} else {
[UINavigationController attemptRotationToDeviceOrientation];
}
Bug Report
Problem
Getting this issue on our radar early:
https://developer.apple.com/forums/thread/707735?answerId=721941022#721941022
What is expected to happen?
This approach used to work, but may not on iOS 16: [[UIDevice currentDevice] setValue:@(orientation) forKey:@"orientation"]
We may need to switch to: https://developer.apple.com/documentation/uikit/uiwindowscene/3975944-requestgeometryupdate/ (which would require building from XCode 14)
What does actually happen?
Information
Command or Code
Environment, Platform, Device
Version information
iOS 16 beta 4
Checklist