我有UITableViewController
其中一个选项卡上的是UINavigationViewController
。 UINavigationController
根视图控制器是UITableViewController,当单击单元格时,出现UIViewController
,必须将其锁定在Landscape
中。在UINavigationController中只处理UIViewController
我希望每个控制器都被锁定在Portrait
中,除了提到的UIViewController
必须锁定在Portrait
之外。
我曾尝试以下:
CustomTabBarController.m:
#import "CustomTabBarController.h"
@implementation CustomTabBarController
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
- (BOOL)shouldAutorotate{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return [self.selectedViewController supportedInterfaceOrientations];
}
@end
CustomNavigationController.h:
#import "CustomNavigationController.h"
@implementation CustomNavigationController
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
-(BOOL)shouldAutorotate
{
return YES;
}
@end
而在UIViewController中那个亩T为锁定在风景,我已经把:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL)shouldAutorotate
{
return YES;
}
但它不工作,我可以将它旋转到横向,它就会锁定在风景,但我希望它在景观自动出现。
有什么建议吗?