首页 > 解决方案 > 方向限制在 iPad 上不起作用

问题描述

我有应用程序只是显示首页。

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
      statusBarColor: Colors.transparent
    ));
    return MaterialApp(
      theme: ThemeData(
      ),
      home: TopPage(title: 'flutter'),
    );
  }
}

class TopPage extends StatefulWidget {
  TopPage({Key key, this.title}) : super(key: key);

  final String title;
  @override
  _TopPageState createState() => _TopPageState();
}

class _TopPageState extends State<TopPage> {
  @override
  void initState() {
    super.initState();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);
  }
}

我以此来限制方向

SystemChrome.setPreferredOrientations([
  DeviceOrientation.portraitUp,
]);

它修复了 Android /Android 平板电脑 / iPhone 上的仅方向纵向。

但是仅在 iPad 中。

它旋转到横向。

如何在 iPad 上停止旋转??


在我的 Xcode Deployment Info.-> 1Device Orientation`

Portlait Lanscape Left Landscape Right

被检查。

因为我需要在其他页面上旋转TopPage

标签: iosiphonexcodeflutteripad

解决方案


默认情况下,iPad 上的应用程序会选择 iPad 多任务处理,并且预计会在所有四个方向上旋转。甚至没有咨询它对优选方向的实现。

UIRequiresFullScreen它可以通过在其Info.plist 中设置来选择退出。


推荐阅读