我在尝试阻止某些视图的方向,但代码不起作用。
我在每个视图中使用以下代码行:
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return UIInterfaceOrientationMaskPortrait;
} else {
return UIInterfaceOrientationMaskAll;
}
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
这段代码在使用UINavigationController的视图中几乎可以正常工作,但是在使用UITabBarController的视图中出现了大问题,因为似乎代码没有被调用。