简体   繁体   中英

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.

I am building my first iOS app. 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).

Under Deployment Info: Deployment Target is set to 7.0 and Universal. iPhone and iPad both use the MainStoryboard main interface, with all four Device Orientations checked for both.

My AppDelegate starts with:

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; it prints "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. 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! 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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