You just need to return a BOOL in that method. If you want just portrait mode, that means:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait) ;
}
If it's fine to be also Portrait Upside down (when in portrait rotate the device 180 degrees), then the method will look like:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
The last condition can be replaced with a call to UIDeviceOrientationIsPortrait(interfaceOrientation)
, which does the same comparison
(cf: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html)
LE: If this doesn't work, you can try using the follow 'hack': try to pop and push the view again (if you're using NavigationController). You can use the popViewControllerAnimated
and pushViewController:animated:
methods to force the controller re-query the required orientation :)
Source: http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html)