Add to main module:
And Process_Globals:
Call Main.SetSupportedOrientation to change orientation.
Tested on iOS 17.
B4X:
#if OBJC
@end
@interface B4IAppDelegate (orientation)
@end
@implementation B4IAppDelegate (orientation)
- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return [b4i_main new]._morientation;
}
#End If
B4X:
Public Sub SetSupportedOrientation(Orientation As Int)
mOrientation = Orientation
If App.KeyController <> Null Then
App.KeyController.As(NativeObject).RunMethod("setNeedsUpdateOfSupportedInterfaceOrientations", Null)
End If
End Sub
And Process_Globals:
B4X:
Public const ORIENTATION_PORTRAIT = 2, ORIENTATION_LANDSCAPE = 24, ORIENTATION_ALL = 30 As Int
Private mOrientation As Int = ORIENTATION_ALL 'ignore
Call Main.SetSupportedOrientation to change orientation.
Tested on iOS 17.