Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS 6 screen rotation without using storyboard

Anyone who's trying the newest iOS 6 beta(version 2 or 3) has the same experience of auto rotation not working?

I am not using storyboard but pure navigation control:

self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window addSubview:navController.view];

And have:

- (BOOL)shouldAutorotateToInterfaceOrientation: ](UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
    return YES;
}
}

- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown;
}

BUT IOS has no espouse at all, works fine with all previous iOS on 3GS/4S and 4.3,5.0.5.1 simulator, but iOS 6 seems just buggy

like image 351
phil88530 Avatar asked Jul 18 '12 15:07

phil88530


2 Answers

Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientations and shouldAutorotate methods.

Read more here.

like image 160
John Smith Avatar answered Nov 07 '22 10:11

John Smith


instead of [self.window addSubview:navController.view];

insert self.window.rootViewController = navController;

like image 39
Medhi Avatar answered Nov 07 '22 09:11

Medhi