Become a MacRumors Supporter for $25/year with no ads, private forums, and more!
  • Did you order new AirTags? We've opened a dedicated AirTags forum.

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
hi, in my app i toggled the portrait, landscape left/right buttons in the project summary. my app contains a view controller as a root view controller, and a table view controller which the user can navigate to when clicking a button in the view controller. i want to let the user to be able to rotate the screen in the table view but not in the view controller. how can i restrict rotation to a view controller?
 

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
"Supporting Multiple Interface Orientations" section of the View Controller Programming Guide.

HI, i read the ios 6 part since shouldAutorotateToInterfaceOrientation: has been deprecated from ios 6 and onwards. however i didn't find an answer to my problem. i toggled the portrait and landscape left from the project summary and in the view controller (root controller) i added the following:
Code:
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationMaskPortrait;
}
when running the app, it opens in portrait but when i rotate the device, the view rotates to landscape left. thus the restriction to one orientation from the ones supported failed. i tried using ShouldAutorotate to restrict it to one orientation but it seems it's not even entering the method (i used nslog to detect that).any hint? i want it to open only in portrait no matter how i rotate the device.
 
Last edited:
Comment

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
I assume you have a navigation controller. Unfortunately the stock navigation controller doesn't forward calls to the new orientation methods to its topViewController. You need to subclass UNavigationController to return the values from the topViewController.
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.