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
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;
}
Did you try with Device and Simulator? Did you check supported orientation in your app_name-Info.plist?
精彩评论