Delphi XE7で実行時にiOS・Androidアプリケーションの画面の向きを固定するサンプルアプリケーションを作成します。
フォームにボタンを3つ配置します。
ボタンを押すと次のような処理を行います。
横固定…画面の向きを横に固定する
縦固定…画面の向きを縦に固定する
ユーザの現状態…画面の向きを固定しない
ソースコードは次のようになります。
procedure TForm1.ButtonLandscapeClick(Sender: TObject);
begin
//横固定
Application.FormFactor.Orientations :=
[TFormOrientation.Landscape, TFormOrientation.InvertedLandscape];
end;
procedure TForm1.ButtonPortraitClick(Sender: TObject);
begin
//縦固定
Application.FormFactor.Orientations :=
[TFormOrientation.Portrait, TFormOrientation.InvertedPortrait];
end;
procedure TForm1.ButtonUserClick(Sender: TObject);
begin
//ユーザの現状態
Application.FormFactor.Orientations :=
[TFormOrientation.Landscape, TFormOrientation.InvertedLandscape,
TFormOrientation.Portrait, TFormOrientation.InvertedPortrait];
end;
実行したところ