I have a UITabBarController presented in portrait mode. On one of the tabs, I have a button that shows the UIViewController modally (a simple segue storyboard does the action).
I want this modal view to display in landscape mode, but I can't get it to rotate automatically.
I have it in the modal view controller
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); }
I added LandscapeLeft to the supported .plist orientations (although this also allows the TabBar to rotate, which I don't want)
I also added this to the ViewDidLoad modal view.
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
but I just can't make it spin by itself.
thanks
EDIT ----
AutoRotate doesn't seem to even get called!
Also, I'm trying to determine the orientation, and this code below always shows 2, regardless of orientation!
if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait) { NSLog(@"1"); self.hostView.frame = CGRectMake(0, 60, 200, 255); } else { NSLog(@"2"); self.hostView.frame = CGRectMake(0, 45, 480, 255); }
EDIT 2 ---
My bad. I think I should have mentioned that I used iOS 6. The display automatically rotates to iOS 5. shouldAutorotateToInterfaceOrientation is deprecated, so I need to read the new methods.
ios cocoa-touch xcode uiinterfaceorientation modalviewcontroller
Darren
source share