0

I know that: By default, an app and a view controller’s supported interface orientations are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom. So when I created a new project with Single View Application template, to perform all orientation in iPhone i add two method below to ViewController.m. And it work!

- (NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotate
{
    return YES;
}

Then i changed some codes in method below of AppDelegate.m to change the root view of application from UIViewController to UINavigationController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
    } else {
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
    }
    if(myNavigationController == nil)
        myNavigationController = [[UINavigationController alloc]initWithRootViewController:self.viewController];

    self.window.rootViewController = self.myNavigationController;
    [self.window makeKeyAndVisible];
    return YES;
}

After that, i can't handle the UIInterfaceOrientationPortraitUpsideDown in iPhone iOS6 simulator. How can i resolve that? I tried to search a bit of code in older topic but it still not work.

Undo
  • 25,519
  • 37
  • 106
  • 129
nghien_rbc
  • 133
  • 1
  • 12
  • possible duplicate of [Orientation issue in ios 6](http://stackoverflow.com/questions/13023936/orientation-issue-in-ios-6) – Vishal Apr 28 '13 at 02:01

1 Answers1

0

Is myNavigationController a property? You reference it as myNavigationController and self.myNAvigationController. Seems inconsistant, especially since you initialize the object referencing the ivar, and then set the window's rootViewController with the property.

Also, you should clarify your question. I think you are asking how to get the iPhone to auto-rotate to upsidedown portrait. The answer is: Don't. The iPhone does not support horizontal rotation locking (un-like the iPad), and goes against design guidelines.

That being said: You may want to check that ALL of your viewControllers implement the rotation delegates, and that they ALL support upside-down rotation for iPhones. I know you said you started with a single-view application template, but there should be no other reason for the rotation being blocked.

Edit: Another thing you should check is your target settings. The "Supported Interface Orientation" section here may override your custom rotation code.

Austin
  • 439
  • 3
  • 10