ios - 在 Delphi 中检测 iPad 方向

标签 ios delphi delphi-xe4

我本以为 XE4 中会有一个 OnRotate 事件,但似乎使用了 OnResize 。明白了。

但是,我需要确定设备的方向。我确信这很简单,但 Google 帮不上忙!

最佳答案

要检测设备的当前方向,您可以使用 statusBarOrientation 方法,该方法是UIApplication 的一部分。类。

尝试这个示例

uses
  iOSapi.UIKit;

function SharedApplication:UIApplication;
begin
  Result:=TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication);
end;

procedure TForm23.Button1Click(Sender: TObject);
var
  LOrientation: Cardinal;
begin
  LOrientation := SharedApplication.statusBarOrientation;
  if (LOrientation = UIDeviceOrientationLandscapeLeft) or (LOrientation = UIDeviceOrientationLandscapeRight) then
    ShowMessage('Landscape')
  else
  if (LOrientation = UIInterfaceOrientationPortrait) then
    ShowMessage('Portrait');
end;

关于ios - 在 Delphi 中检测 iPad 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17592637/

相关文章:

ios - iOS : Use of undeclared identifier error in simple calculator [closed]

ios - 获取NSManagedObject属性验证正则表达式

delphi - Delphi-如何检查数据集是否已获取所有行?

delphi - 如何设置FMX.Panel颜色?

delphi - 如何在 Delphi 中创建有吸引力的侧栏菜单

ios - 为什么 Firebase 远程配置不更新值?

ios - 如何将 VNDetectRectanglesRequest 改进为 VNDetectCarRequest?

delphi - 如何设置 FMX.Canvas 上光标下像素的颜色?

delphi - Delphi 2010 Enterprise 版本的哪些功能对您有值(value),为什么?

Delphi XE4 - 八进制常数像十进制常数一样工作