3
votes

Anyway to lock orientation to per se Portrait for only a specific form and not the whole application? Using Delphi xe6, for iOS. Can't seem to find anything by googling. Thank you!

Update:

My underlying issue is that I'm using a zbar unit for scanning and when the screen rotates, the display from the camera view does not. So the app goes to landscape, but the view from the scanner is still portrait, thus making the view look sideways. From what I've googled and tooled around on my own, it appears that locking the orientation maybe easier so here is where I am.

I've found this article: http://www.delphifeeds.com/go/s/84941, but to no avail, the one form I don't want to rotate, still rotates.

I've implemented this code for the time being, although I'm not very found of it. Was just a quick, fix work-around.. I put everything ontop of a layout and on the form's resize event:

  with LayoutOrientation do
  begin
    if Clientwidth > ClientHeight then
    begin
      Align := TAlignLayout.None;
      width := ClientHeight;
      height := Clientwidth;
      RotationAngle := 90;
      RotationCenter.X := 0.948;
    end else begin
      RotationAngle := 0;
      RotationCenter.X := 0.5;
      Align := TAlignLayout.Client;
    end;
  end;

Meh, I don't like this because the app still repaints when it doesn't need to and also the status bar showing at the top still, gives it a funky look. This for the time being works - but really looks like I hacked it, which in this case I did..

2
Have you checked out the AndroidApi's for delphi. You can probably do it by handling the native android code. I have no experience with that thoughRemi
I am developing for iOS as the question stated.ThisGuy
Then probably the iOSApi's. Sorry that i can't help moreRemi
Not sure if you ever found a solution to this, but maybe a few changes to what I did here could give you your desired effect/behaviour I only use one form tough stackoverflow.com/questions/33387402/…Peter-John Jansen

2 Answers

-1
votes

Update Application.FormFactor.Orientations before and after showing your form.

  Application.FormFactor.Orientations := [TFormOrientation.Portrait];
  ScannerForm.ShowModal;
  Application.FormFactor.Orientations := [TFormOrientation.Portrait, TFormOrientation.Landscape, TFormOrientation.InvertedLandscape];
-2
votes

It actually depends how do you generally controll your application orientation.

If you use Layouts to control orientation you could force the use of same layour for every oriantation.

If you are creating different forms for different orientation you can force your application to use same for for every orientation.