I have a UIView thats inside a navigation controller, I am trying to prevent this view from going into Landscape however the method I am trying to use never fires.. code is below any help would be greatly appreciated..
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
return NO;
}
else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
return NO;
}
return NO;
}
You should set
return NO;for the parent navigation controller or on aUIViewController, not aUIView.Also, this works just the same with less code:
iOS 5.x
iOS 6
As of iOS 6,
shouldAutorotateToInterfaceOrientation:is deprecated. If the view controller does not override thesupportedInterfaceOrientationsmethod,UIKitobtains the default rotations from the app delegate or the app’s Info.plist file.You will need to use: