the ShouldAutoRotate function no longer works in iOS 16, how to solve the problem?
I found something here, but can not implement myself.
B4X:
Sub Main_ShouldAutoRotate As Boolean
Log("Main_ShouldAutoRotate")
If IsSetOrientation Then
If DeviceOrientation = "Portrait" And OrientationModus = "Landscape" Then
Return False
else If DeviceOrientation <> "Portrait" And OrientationModus = "Portrait" Then
Return False
Else
Return True
End If
Else
Return False
End If
End Sub
There is no error message, it's just that whetherwoll the "Main_ShouldAutoRotate" sub returns False, the iPhone still changes orientation.
This was not the case before iOS-16.
I've tried several things but they didn't work on iOS 16.
There is a new API that allows you to explicitly rotate the screen. What exactly are you trying to do?
I've tried several things but they didn't work on iOS 16.
There is a new API that allows you to explicitly rotate the screen. What exactly are you trying to do?
I have 2 layouts in my app, one for horizontal and one for vertical alignment.
Via the App-Setting the user can choose between the 2 alignments.
Therefore, the alignment should not change automatically. This has also worked well until iOS 15.
Apple writes here that from iOS-16 you can use the new ViewController "setNeedsUpdateOfSupportedInterface", but doesn't write how and doesn't give an example.
For some of my applications this feature is absolutely necessary, without it the functionality of the application is otherwise very limited.
Update your apps to use new features, and test your apps against API changes.
developer.apple.com
Deprecations
[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