Hi,
I need to rotate the screen at runtime when I open a form.
Until the release of IOS 13 this code worked perfectly:
procedure ChangeOrientation(toOrientation: UIInterfaceOrientation; possibleOrientations: TScreenOrientations);
var
win : UIWindow;
App : UIApplication;
viewController : UIViewController;
oucon: UIViewController;
begin
Application.FormFactor.Orientations := []; //Change supported orientations
App := TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication);
win := TUIWindow.Wrap(App.windows.objectAtIndex(0)); //The first Windows is always the main Window
App.setStatusBarOrientation(toOrientation);
{After you have changed your statusbar orientation set the
Supported orientation/orientations to whatever you need}
Application.FormFactor.Orientations := possibleOrientations;
viewController := TUIViewController.Wrap(TUIViewController.alloc.init);//dummy ViewController
oucon := TUIViewController.Wrap(TUIViewController.alloc.init);
{Now we are creating a new Viewcontroller now when it is created
it will have to check what is the supported orientations}
oucon := win.rootViewController;//we store all our current content to the new ViewController
Win.setRootViewController(viewController);
Win.makeKeyAndVisible;// We display the Dummy viewcontroller
win.setRootViewController(oucon);
win.makeKeyAndVisible;
{And now we Display our original Content in a new Viewcontroller
with our new Supported orientations}
end;
However, since the release of IOS 13 the screen locks on the set orientation but does not rotate. So if I set Landscape orientation the screen remains in Portrait orientation until I physically turn the phone around, at which point it rightly remains locked on that orientation.
This is a real disaster because then, until the phone is turned, all the controls ( finger position, object position,..) are wrong.