iPad 5.1 Simulator will NOT rotate?


#1

I added the following to BOTH DetailViewController and ItemsViewController. I’m NOT hitting the code at all (via breakpoint), even if just simply return YES. ALL the orientations are enabled in my summary page. What am I missing?

- (BOOL)shouldAutoRotateToInterfaceOrientation:(UIInterfaceOrientation)o
{
    BOOL rc = NO;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        rc = YES;
    }
    else {
        rc = (o == UIInterfaceOrientationPortrait ||
              o == UIInterfaceOrientationPortraitUpsideDown);
    }
    return rc;
}

#2

Note that if I run the authors’ downloaded code, rotation works, so yes my code is the guilty party. I do follow their examples pretty closely though, and only deviate in minor details like the code above. But where/how should I start looking? I’ve been playing with this for an hour now and it’s driving me nuts.


#3

Are you setting up your root view controller properly?

If your are using the AppDelegate, your code code should look like this:

// AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    
    // Override point for customization after application launch.
    self.viewController = [[[LettersViewController alloc] init] autorelease];
    self.navigationController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
    
    self.window.rootViewController = navigationController;
    [self.window makeKeyAndVisible];

    return YES;
}

I have changed my mind, because you have a case error in your method name:
[color=#FF0000]- (BOOL)shouldAutoRotateToInterfaceOrientation:(UIInterfaceOrientation)o[/color]

The method name should look like this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)o

Avoid typing in method names. Use Xcode’s autocompletion or copy and paste from the original declaration.


#4

You da man! Thanks.