我本以为 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/