Alex Rivera | Logout

How do I force a specific UIInterfaceOrientation on an individual view in a UINavigationController?

Asked 2011-05-19T21:07:25.543
21

Okay, so here's the situation:

I have an app in which I only want ONE specific view in a UINavigationController to have a landscape orientation. This view is a UIImageView that I'm capturing a signature on (THAT part works awesome). So, like this:

previous view --> signature view --> next view
 (portrait)        (landscape)       (portrait)

I can't seem to find a good way to force the device orientation to landscape on that signature screen. It'll never make sense to have a portrait orientation on the signature view because there's really not adequate room for signing in that screen width.

So, any bright ideas on how to accomplish this? I've considered possibly doing the signature view modally, thus breaking out of the navigation controller. Thoughts?

Edit
Report

1 Answer

0

I have an app that has landscape only views that even starts in landscape. This was working fine in iOS 5.x but stopped working in iOS 6.x

After trying many many things, some more questionable than others, I found a solution that to me is clear and predictable.

I did several things.

-- I kept the views in landscape mode in IB.

-- I checked both landscape modes in the project settings - there a four icons there to control it

-- Orientation mgmt has changed in iOS 6.x. I had to overwrite a few methods to support changing to landscape

this method is for iOS 5.x

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    // Return YES for supported orientations.
    return (interfaceOrientation & UIInterfaceOrientationMaskLandscape);
}

these 2 methods are for iOS 6.x

- (NSUInteger)supportedInterfaceOrientations
{
    NSUInteger supportedOrientations = UIInterfaceOrientationMaskLandscape;
    return supportedOrientations;
}


- (BOOL)shouldAutorotate
{
    return YES;
}

-- But the key was to change the logic in the AppDelegate. Original code I had there was adding a subview (controller.view) to the window. This stopped working in iOS 6.x - I changed the call to window.setRootController. That was the final step that sealed it - it would not work without making this final change

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{        
    //[self.window addSubview:viewController.view];
    [self.window setRootViewController:viewController];
    [self.window makeKeyAndVisible];


    return YES;
}
answered 2013-04-08T06:29:06.080

Your Answer