1

以下是我的主要观点。

  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.我想锁定直接连接到tabBarController(ex - Grid1ViewController)的每个控制器的旋转。但我需要旋转应用程序中使用的一些控制器。请参考下图。A、B、C、D 和 E 是控制器。 控制器轮换

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

    (BOOL) 应该自动旋转到接口方向(UIInterfaceOrientation) 到接口方向{

    NSLog(@"5 转"); 返回(toInterfaceOrientation == UIInterfaceOrientationPortrait);} // 对于IOS 6

    -(BOOL)shouldAutorotate { NSLog(@"shouldAutorotate"); 返回是;} (NSUInteger)supportedInterfaceOrientations { NSLog(@"6 旋转"); 返回 UIInterfaceOrientationMaskPortrait;}

我怎样才能做到这一点?请帮忙。先感谢您。

4

0 回答 0