The problem of orientation of the portrait mode with tabbarcontroller?
source link: https://www.codesd.com/item/the-problem-of-orientation-of-the-portrait-mode-with-tabbarcontroller.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The problem of orientation of the portrait mode with tabbarcontroller?
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;
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK