当IOS 5中有UITabBar时,锁定单个控制器的屏幕方向。 6

时间:2013-05-16 08:51:41

标签: xcode ios5 ios6 uitabbarcontroller appdelegate

以下是我的主要观点。

  1. 我是IOS开发的新手
  2. 我需要在我的IOS应用程序中支持IOS 5和IOS 6
  3. 我在AppDeligate文件中有一个UITabBarController,如下所示。

    UIViewController * viewController1 = [[[Grid1ViewController alloc] initWithNibName:@“Grid1ViewController”bundle:nil] autorelease]; UIViewController * viewController2 = [[[VideoListViewController alloc] initWithNibName:@“VideoListViewController”bundle:nil] autorelease]; UIViewController * viewController3 = [[[MusicViewController alloc] initWithNibName:@“MusicViewController”bundle:nil] autorelease]; UIViewController * viewController4 = [[[GalleryViewController alloc] initWithNibName:@“GalleryViewController”bundle:nil] autorelease];

    UINavigationController * myNav1 = [[UINavigationController alloc] initWithRootViewController:viewController1]; UINavigationController * myNav2 = [[UINavigationController alloc] initWithRootViewController:viewController2];  UINavigationController * myNav3 = [[UINavigationController alloc] initWithRootViewController:viewController3]; UINavigationController * myNav4 = [[UINavigationController alloc] initWithRootViewController:viewController4];

    UIImage * navBackgroundImg = [UIImage imageNamed:@“aa.png”];

    [myNav1.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault]; [myNav2.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault]; [myNav3.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault]; [myNav4.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault];

    self.tabBarController = [[[[UITabBarController alloc] init] autorelease]; self.tabBarController.viewControllers = [NSArray arrayWithObjects:myNav1,myNav2,myNav3,myNav4,nil];

  4. 4.我想锁定直接连接到tabBarController(ex-Grid1ViewController)的每个控制器的旋转。但我需要旋转应用程序中使用的某个控制器。请参考下图。 A,B,C,D和E是控制器。 rotation of controllers

    1. 我尝试在控制器和AppDeligate文件中实现以下方法。但没有奏效。当允许旋转时,整个应用程序开始旋转。

      (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)toInterfaceOrientation {

      NSLog(@“5轮”); return(toInterfaceOrientation == UIInterfaceOrientationPortrait); } //对于IOS 6

      - (BOOL)shouldAutorotate { 的NSLog(@ “shouldAutorotate”); 返回YES; } (NSUInteger)supportedInterfaceOrientations { NSLog(@“6轮”); 返回UIInterfaceOrientationMaskPortrait; }

    2. 我怎样才能做到这一点?请帮忙。提前谢谢。

0 个答案:

没有答案