【问题标题】:Limitation of Orientation doesn't work on iPad方向限制在 iPad 上不起作用
【发布时间】:2020-12-24 05:01:43
【问题描述】:

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

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以外的页面上旋转

【问题讨论】:

    标签: ios iphone xcode flutter ipad


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-11-24
      • 2019-08-24
      • 2012-06-13
      • 2013-12-10
      • 1970-01-01
      • 2011-10-06
      • 1970-01-01
      • 2015-08-06
      相关资源
      最近更新 更多