Any suggestions?
[Orientation] BUG IN CLIENT OF UIKIT: Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:)
iOS16
I found the following problems with the new API:
- The previous several animations were abnormal
- If the return before supportedInterfaceOrientation does not support rotation direction, even if later modified return to support the direction of rotation, and then call requestGeometryUpdate, also returns the error, Rather than read supportedInterfaceOrientation first, determine whether to support and then returns the error
- Gravity sensing is also possible due to requestGeometryUpdate
Just want to bump that I am also having trouble with this, all calls to requestGeometryUpdate() are denied.
iOS 16 beta 4, iPhone 12 Pro
Second this issue. Xcode 14 GM iOS 16 GM iPhone 12 mini
How about Release version?
I do not have newer iPhone. I was encounterd this message in iOS16-iPhone14 Simulator on Xcode4.0 cantidate. but, I installed iPadOS16 Beta7 (20B5027f) into iPad mini5, UIDevice.orientaion was work well (The spinning animation was a little weird though).
It's just my imagination
https://developer.apple.com/documentation/uikit/uidevice/1620053-orientation?language=objc Seeing that orientation isn't deprecated here,
in his UIKit in iOS16.0 he tried to change the internal implementation of UIDevice.orientaion to his UIWindowsScene's but failed and only the developer Doesn't it mean that the console log of [Orientation] .... was displayed as a warning? With iOS 16.1, the console display will also disappear, and I would like to wait and see how UIDevice.orientation works properly.
Orientation is not happening in iOS 16 with Latest Xcode version for UIDevice orientation. Can any one have the sample code for requestGeometryUpdate for objective c.
**Use below code on rotation and after that do write code of UI update with delay of 0.5 or 1.0 ** @try {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000 // Xcode 14 and iOS 16, or greater
[vc setNeedsUpdateOfSupportedInterfaceOrientations];
[vc.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
#endif
} @catch (NSException *exception) {
NSLog(@"UpdateOrientationForiOS16 catch error: %@", [exception description]);
}
**Force attempt Orientation - attemptRotationToDeviceOrientation ** // requiredMask = UIInterfaceOrientationMaskPortrait @try {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160000 // Xcode 14 and iOS 16, or greater
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array[0];
[vc setNeedsUpdateOfSupportedInterfaceOrientations];
[vc.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:requiredMask];
[scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) {
//draw design again after orinetation changed
errorCompletion([error description]);
//NSLog(@"requestGeometryUpdateWithPreferences error: %@", [error description]);
}];
#endif
} @catch (NSException *exception) {
NSLog(@"UpdateForceAttemptOrientationForiOS16 catch error: %@", [exception description]);
}
In iOS 16 the following code is deprecated:
setValue(orientation.rawValue, forKey: "orientation")
We had a working alternative using attemptRotationToDeviceOrientation(), but this then also got deprecated.
Then requestGeometryUpdate() was introduced. We use UIWindowScene.requestGeometryUpdate() instead now. This worked for iOS 16. But from iOS 16.1 this isn’t working. To fix this we also now need to call UIViewController.setNeedsUpdateOfSupportedInterfaceOrientations() afterwards.
The API documentation doesn’t mention the need to call setNeedsUpdateOfSupportedInterfaceOrientations. So it’s not clear if this is a workaround or the intended way to change the interface orientation.
It would be nice to update the documentation to clarify the expected behavior and usage of requestGeometryUpdate() and setNeedsUpdateOfSupportedInterfaceOrientations().