简体   繁体   English

状态栏可以旋转,但应用程序不能在iPhone上运行-在iPad上可以正常使用吗?

[英]Status bar rotates but application does not, on iPhone- works fine on iPad?

Long time lurker, always tried very hard to search and have found many answers this way. 长期潜伏,总是非常努力地寻找并以这种方式找到了许多答案。 This is the first time I have found nothing that fixes my problem. 这是我第一次找不到能解决我的问题的东西。 This is also my first solo app, as I am a new developer. 这也是我的第一个个人应用程序,因为我是一名新开发人员。

I have two devices- an iOS 8.1 iPhone 6, and an iOS 7 iPad Mini Retina 2. 我有两个设备-iOS 8.1 iPhone 6和iOS 7 iPad Mini Retina 2。

I am building my first iOS app. 我正在构建我的第一个iOS应用。 It uses storyboards for a UITabBarController with three tabs, each of which contains a UINavigationController and a custom sub view controller (such as a subclass of tabbarcontroller or collectionviewcontroller). 它为带有三个选项卡的UITabBarController使用情节提要板,每个选项卡均包含一个UINavigationController和一个自定义子视图控制器(例如tabbarcontroller或collectionviewcontroller的子类)。

Under Deployment Info: Deployment Target is set to 7.0 and Universal. 在“部署信息”下:“部署目标”设置为7.0和“通用”。 iPhone and iPad both use the MainStoryboard main interface, with all four Device Orientations checked for both. iPhone和iPad均使用MainStoryboard主界面,并同时检查了所有四个“设备方向”。

My AppDelegate starts with: 我的AppDelegate开始于:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];

UITabBarController *initViewController = (UITabBarController *)[storyboard instantiateViewControllerWithIdentifier:@"rootTabBarController"];

NSLog(@"%d %d",initViewController.shouldAutorotate,initViewController.shouldAutomaticallyForwardRotationMethods);

[self.window setRootViewController:initViewController];

Note the NSLog; 注意NSLog; it prints "1 0". 它打印“ 1 0”。

So from what I can see- the tab bar should auto rotate. 因此,据我所知-标签栏应自动旋转。

On my iPhone, when I turn the device sideways, the status bar on the top rotates- but the content remains upright. 在我的iPhone上,当我向侧面转动设备时,顶部的状态栏会旋转-但内容仍保持竖直。 If I hit the Home button and switch back to the app while holding it sideways, everything goes wonky- the content rotates but doesn't rearrange the layout, so it remains vertical, and thus gets cut off and there's a big black section on the side. 如果我按住主屏幕按钮并侧向切换回该应用程序,一切都会变样-内容旋转但不重新排列布局,因此它保持垂直状态,因此被截断,并且屏幕上有一个很大的黑色部分侧。

On my iPad, though- everything works fine! 不过,在我的iPad上,一切正常! The application rotates as expected and resizes itself. 应用程序将按预期旋转并调整其大小。

What am I doing wrong here? 我在这里做错了什么? Thank you tremendously for any help. 非常感谢您的帮助。

Why are you programmatically loading the storyboard? 为什么要以编程方式加载情节提要? If there's no specific need to do that, I'd suggest just using the template app delegate code. 如果不需要这样做,我建议您仅使用模板应用程序委托代码。 Better yet, create a completely new, fresh project and just copy over your storyboard. 更好的是,创建一个全新的项目,然后将其复制到情节提要中。 It won't necessarily make sense, but... I bet it will work! 不一定有道理,但是...我敢打赌,它将成功!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM