【发布时间】:2016-01-28 00:15:58
【问题描述】:
基本上我想要实现的是当用户在应用程序的某个部分根据需要更改屏幕旋转时,我为 Andriod 工作,但我不明白为什么它不适用于 iOS
procedure TForm1.Button1Click(Sender: TObject);
var
ScreenService: IFMXScreenService;
OrientSet: TScreenOrientations;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenService))
then
begin
OrientSet := [TScreenOrientation.soLandscape];//<- Break point set here and line is executed
ScreenService.SetScreenOrientation(OrientSet);
end;
end;
取自这里:How to prevent screen rotation with android development in delphi xe5 Firemonkey
ScreenService.SetScreenOrientation 被执行并且不会引发异常但方向没有改变,我还在 Project>Options>Application>Orientation 中设置了 Enable customorientation 但这也没有有什么作用。
让我感到奇怪的是,如果它不被支持,那么不应该这样
if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenService))
返回假?甚至没有进入开始
在我将其设置为横向后,我添加了一个测试按钮来检查屏幕方向
if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenService))
then
begin
case ScreenService.GetScreenOrientation of
TScreenOrientation.Portrait: ShowMessage('Portrait');
TScreenOrientation.Landscape: ShowMessage('landscape');
TScreenOrientation.InvertedPortrait: ShowMessage('Inverted-Portrait');
TScreenOrientation.InvertedLandscape: ShowMessage('Inverted-Landscape');
else ShowMessage('not set');
end;
end;
如果它在设置为横向后是纵向的,它仍然会显示纵向
更新 1:我也尝试过更改
OrientSet := [TScreenOrientation.soLandscape] // <- Deprecated
到
OrientSet := [TScreenOrientation.Landscape]
但是行为还是一样的
【问题讨论】:
标签: ios delphi firemonkey delphi-10-seattle