user5664685
user5664685

Reputation: 61

Is supportedInterfaceOrientations settings working properly in simulator?

I have a project where all views are meant to be in portrait only, except one which is only landscape and no auto-rotation. I set supported orientations to portrait and landscape in project settings. Then I set these functions for each view controller:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft; // or Right of course
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

-(BOOL)shouldAutorotate
{
    return NO;
}

but it does not work. The simulator allows all views to rotate and seems to ignore the settings altogether. Am I doing something wrong, or is it a bug in the simulator?

Upvotes: 0

Views: 72

Answers (2)

user5664685
user5664685

Reputation: 61

I finally had to use a bit of a hack to get it working: I put this line in viewDidLoad: self.view.transform = CGAffineTransformMakeRotation(M_PI/2); everything works fine now

Upvotes: 0

Woodstock
Woodstock

Reputation: 22926

Most likely the issue is that you've defined the permitted orientations in info.plist which overrides anything specified in code.

Thus you probably need to remove the entries from info.plist.

Upvotes: 1

Related Questions