views:

50

answers:

2

Hi all

Using tabbarcontroller, shouldAutorotateToInterfaceOrientation: method not calling for portrait mode while for other three orientation its calling perfectly. Did any have any idea about this ?

thanks

A: 

Did you try with Device and Simulator? Did you check supported orientation in your app_name-Info.plist?

Greensource
I try in both. Same result. and in .plist i am not changing anything or restrict any thing ?
sandy
I'ts strange, are you sure you don't have "Supported interface orientation" key in the PList file?
Greensource
damm sure .. nuthing related to orientation.
sandy
A: 

Even i faced the problem , If you just want to know whether the orientation of the device changed or not use notification instead of shouldAutorotateToInterfaceOrientation.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
-(void)orientationChanged:(NSNotification *)dict
{
    UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
    //Your code
}

For Original problem, By default shouldAutorotateToInterfaceOrientation return YES for UIDeviceOrientationPortrait, If you returned NO in shouldAutorotateToInterfaceOrientation method, device will think that its in UIDeviceOrientationPortrait mode only hence the method shouldAutorotateToInterfaceOrientation is not called for UIDeviceOrientationPortrait.

    (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
       //your code
        return NO;
 }
Chandan Shetty SP
Are you returning NO in shouldAutorotateToInterfaceOrientation method always.
Chandan Shetty SP