Main storyboard setting affect rotation function in iOS8

87 views Asked by At

In my app, the rotation works fine in iOS7 but not working in iOS8.

enter image description here

As you can see, the status bar rotates, but the view controller does not.

I found the issue is caused by main storyboard setting, but I have no idea why it cased the issue. I just removed main storyboard setting in project file and everything works fine in iOS8.

Following is my codes to load storyboard.

[self setMainStoryboard:[UIStoryboard storyboardWithName:@"MainStoryboard-ipad" bundle:nil]];
UIViewController *vc = [mainStoryboard instantiateInitialViewController];

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
[self.window setRootViewController:vc];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

Maybe I used the wrong way to load storyboard?

1

There are 1 answers

0
Hubert Wang On

I fix the problem, but I think this might not be a good solution. It's just a workaround. Anyway, here is what I have done. If you run into the same problem, you can try removing main storyboard setting in your target.

enter image description here

That's it, no further steps. Everything is fine after I remove main storyboard setting. Maybe the way I load main storyboard is incorrect or there is something wrong with my setting of storyboard.

Following is the codes I used to load storyboard:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
UIViewController *vc = [storyboard instantiateInitialViewController];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

// Override point for customization after application launch.
[self.window setRootViewController:nav];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

If anyone know the correct way to use main storyboard, please give me some feedback. Thanks!