解决iPhone 6 Plus横屏启动界面错乱的问题

项目要求适配iPhone6和iPhone 6 Plus,后期测试的时候发现了一个奇特的Bug。因为iPhone 6 Plus有独特的横屏模式,横屏模式启动应用会造成界面错乱,下半部分变成黑色:

error
error

这样的情况有几个前提:

  1. 应用单独导入了6 Plus的启动图片,也就是适配了iPhone 6 Plus。
  2. 应用支持横屏方向。
  3. 根视图为UITabBarController。
  4. 应用横屏情况下启动。

解决办法:

  1. AppDelegate中,在didFinishLaunchingWithOptions方法中创建window前先加入:
    application.statusBarOrientation = UIInterfaceOrientationPortrait;
  2. 在rootController,viewDidAppear方法中添加:(解决旋转界面错乱)
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait| UIInterfaceOrientationLandscapeLeft|UIInterfaceOrientationLandscapeRight];
原文地址:https://www.cnblogs.com/huangh/p/5028965.html