agu*_*oll 6 mobile android ios flutter
完整日志:无法更改设备方向:错误域=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,
]);
}
Run Code Online (Sandbox Code Playgroud)
我尝试以编程方式更改设备方向,但没有成功,正在 android 和 Iphone 模拟器上工作,但不在真正的 Ipad 上。
默认情况下,iPad 允许多任务处理,并且其方向无法锁定。如果您需要在 iPad 上锁定方向,请将以下内容添加到 Info.plist,将选项“需要全屏”设置为“是”:
<key>UIRequiresFullScreen</key>
<true/>
Run Code Online (Sandbox Code Playgroud)
摘自:https: //capacitorjs.com/docs/apis/screen-orientation
也许它也会帮助我的颤振兄弟:)
归档时间: |
|
查看次数: |
400 次 |
最近记录: |