我有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;
}
但它不工作,我可以將它旋轉到橫向,它就會鎖定在風景,但我希望它在景觀自動出現。
有什麼建議嗎?