美文网首页iOS bug修复iOS DeveloperiOS
解决iPhone 6 Plus横屏启动界面错乱的问题

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

作者: Levi_ | 来源:发表于2015-03-26 22:12 被阅读1298次

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

errorerror

这样的情况有几个前提:

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

解决办法:

  1. AppDelegate中,在didFinishLaunchingWithOptions方法中创建window前先加入:
application.statusBarOrientation = UIInterfaceOrientationPortrait;
  1. 在rootController,viewDidAppear方法中添加:(解决旋转界面错乱)
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait| UIInterfaceOrientationLandscapeLeft|UIInterfaceOrientationLandscapeRight];

相关文章

网友评论

  • lzh_coder:大神,完美解决这个问题了吗?为什么我的项目不适用啊?
  • z_hy:发现当应用支持横屏时,这样写还是会造成页面错乱的问题,在rootViewController的viewDidAppear方法里面还是用portrait模式,在需要横屏的vc的viewDidAppear方法页面转换成landscapeRight || landscapeLeft 才是好用的。请问这是因为什么?

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

本文链接:https://www.haomeiwen.com/subject/aiqnxttx.html