views:

429

answers:

1

Hi

I need to block rotation to landscape orientation because my app crashes when it attempts to rotate views to landscape.

How do I block rotation to landscape and where can I setup the block such that it applies to all my views?

Thanks

+1  A: 

In your view controllers:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    if (interfaceOrientation==UIInterfaceOrientationPortrait ) {
        return YES;
    } else {
        return NO;
    }
}

This will prevent your views from trying to rotate to landscape or upsidedown-portrait. However, this should be default. If you haven't set up code to handle landscape orientation then the views shouldn't be trying to rotate anyway. Your crashing is most likely coming from somewhere else.

TechZen