Flutter:无法在 Ipad 上更改设备方向

问题描述 投票:0回答:1

完整日志: 无法更改设备方向:错误域=UISceneErrorDomain代码=101“当前窗口模式不允许以编程方式更改界面方向。” UserInfo={NSLocalizedDescription=当前窗口模式不允许以编程方式更改界面方向。}

void _toggleFullScreen() async {
   
   await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
    await SystemChrome.setPreferredOrientations(const [
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeRight,
    ]);
  }

  void _togglePortrait() async {
   
    await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
    await SystemChrome.setPreferredOrientations(const [
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
  }

我尝试以编程方式更改设备方向,但没有成功,正在 Android 和 Iphone 模拟器上工作,但不能在真正的 Ipad 上工作。

android ios flutter mobile
1个回答
0
投票

iPad 方向锁

默认情况下,iPad 允许多任务处理,并且其方向无法锁定。如果您需要在 iPad 上锁定方向,请将以下内容添加到 Info.plist,将选项“需要全屏”设置为“是”:

UI 需要全屏

摘自: https://capacitorjs.com/docs/apis/screen-orientation

也许它也会帮助我的扑扑兄弟:)

© www.soinside.com 2019 - 2024. All rights reserved.