Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

isthisonetaken

macrumors regular
Original poster
Jun 29, 2006
123
0
Hey All,

I am in the beginning stages of an app for a client who wants the iPhone app to just work in Portrait mode. However, there is one view which they want in Landscape mode ONLY. I've been onto the dev forums and StackExchange and am coming back with a lot of hacks for trying to force a view to be just landscape when pushed to it, but none of them are working in iOS 6. What I'm looking for is a UITabBarController that contains UINavigationControllers and in one of those Nav Controllers, one of the views when pushed should auto-rotate to Landscape with the users phone still in Portrait, so they know to rotate the phone.

However, I would also be able to work with it (assuming the above isn't possible anymore with iOS 6) so that just the one view controller works in all orientations, but all the rest in the app work in Portrait only.

Is this possible? Any thoughts?

Thanks
 

isthisonetaken

macrumors regular
Original poster
Jun 29, 2006
123
0
Step 1:
I started by creating a new test project and chose the tabbar template just to be up and running with a tab bar. By default, it has Portrait and both Landscape options chosen for supported orientations.

Step 2:
I embedded the first view controller in a UINavigationController, set its title and added a UIBarButton item as the right button.

Step 3:
Added a UIViewController and set its orientation (in IB) to Landscape, gave it a different background colour (just to easily recognize that it's loaded). I created a new UIViewController subclass and set that for the class for the landscape view controller in IB.

Step 4:
Added a segue from the bar button in the first view to the newly created view controller with a push transition.

Step 5:
These are the 2 methods I found in the link dejo provided (and the docs when it told me shouldAutorotateToInterfaceOrientation: was deprecated in iOS 6

Code:
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeLeft;
}

So from the link, it says that supportedInterfaceOrientations should set out what orientations the view controller will support (so for this test, just Landscape Left) and preferredInterfaceOrientationForPresentation says what orientation I want the view to be in when it's presented (again, Landscape Left).

I'll note now that the link kept mentioning these only take effect when presented in full screen, and I'm not quite sure what that refers to on the iPhone?

With this all setup, I ran in the simulator and when I hit the button, the second view controller loads, but in Portrait. If I rotate the simulator, the view does indeed rotate. However, it also rotates for the first view controller.

I tried adding the same methods above, but set to Portrait only, and it still rotates.

So at this point, I've got the test project all set up and with the methods and code that I believe should work to allow the app to work only in Portrait mode, except for the new view controller I added that should always be in Landscape Left. At this point I'm confused as to what I should be looking into to get this working...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.