Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 6 autorotation in simulator varies from actual iOS 6 device

My app will not autorotate in the iOS 6 GM simulator but it does with the same version of iOS on the device. Could this be a simulator bug? The app is using deprecated autorotation methods, but they are working fine on the device itself which makes me wonder if the simulator APIs are different?

like image 597
johnbakers Avatar asked Sep 13 '12 12:09

johnbakers


2 Answers

It should still work with the deprecated rotate methods, but you need to add the following to your didFinishLaunchingWithOptions: method:

self.window.rootViewController = yourRootViewController;

This tells the main window what view controller to send the rotate notifications to. This is new with the iOS 6.0 SDK.

like image 141
Jeff Loughlin Avatar answered Nov 15 '22 21:11

Jeff Loughlin


This is what I added to get my app working again:

// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return YES;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
like image 34
rckoenes Avatar answered Nov 15 '22 19:11

rckoenes