我的应用程序有一个带有五个选项卡的 UITabBarController。我只需要为第五个选项卡旋转方向。通过子类化 UITabBarController,我能够让所有五个旋转到横向
@implementation TabBarControllerRotate
-(BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
//return (interfaceOrientation == UIInterfaceOrientationPortrait);
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight
|| interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| interfaceOrientation == UIInterfaceOrientationPortrait);
}
@结尾
if(tbc == nil){
//tbc = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tbc = [[TabBarControllerRotate alloc] initWithNibName:nil bundle:nil]; ////// new //////
……
tbc.viewControllers =
[NSArray arrayWithObjects:viewController1, viewController2, viewController3
,viewController4,viewController5, nil];
我现在需要关闭 viewController1 - 4 的旋转;我尝试通过将以下代码添加到这些 viewController 的四个 *.m 文件来执行此操作,但未成功。
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
return NO;
}
请告诉我如何完成 R。感谢阅读,马克