UITabBar问题,多个UINavigationController和设备方向

时间:2011-11-29 18:02:17

标签: objective-c ios ios5

我有一个UITabBar,在我的AppDelegate.m中创建了2个UINavigationController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ...

    UINavigationController *navController1, *navController2;
    PolyPage *viewController1 = [[PolyPage alloc] init];
    PolyPage *viewController2 = [[PolyPage alloc] init];

    navController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
    navController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];

    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:navController1, navController2, nil];

    ...
    return YES
}

我的视图控制器是相同的。在PolyPage.m我有方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{    
    if (UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:CGPointMake(150, self.tableView.contentOffset.y + 240)];
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];

        imageViewer = [[ImageViewer alloc] initWithDataSource:[NSArray arrayWithObject:cell.imageView.image]];
        [self.navigationController presentModalViewController:imageViewer animated:YES];
    }
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

此方法仅使用UITabBar中的第一个导航控制器显示我的模态视图控制器。 我想让它适用于两个导航控制器。

0 个答案:

没有答案