我有一个包含UITabBarController的UINavigationController的根视图。标签栏控制器有两个简单的视图。当它首次在iOS 6模拟器或设备上启动时,第一个视图上方会出现一个间隙。切换到第二个选项卡然后再返回将使间隙消失。从iOS 6开始才开始发生这种情况。iOS5正常运行。有什么想法改变了吗?

屏幕截图:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    UIView *dummyView1 = [[UIView alloc] init];
    [dummyView1 setBackgroundColor:[UIColor redColor]];
    UIViewController *dummyViewController1 = [[UIViewController alloc] init];
    [dummyViewController1 setView:dummyView1];

    UIView *dummyView2 = [[UIView alloc] init];
    [dummyView2 setBackgroundColor:[UIColor blueColor]];
    UIViewController *dummyViewController2 = [[UIViewController alloc] init];
    [dummyViewController2 setView:dummyView2];

    NSArray *viewControllers = [NSArray arrayWithObjects:dummyViewController1, dummyViewController2, nil];

    [tabBarController setViewControllers:viewControllers];

    UINavigationController *rootNavController = [[UINavigationController alloc] initWithRootViewController:tabBarController];
    [[self window] setRootViewController:rootNavController];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

最佳答案

Apple明确告诉我们,我相信《应用程序编程指南》(或《 ViewController指南》)不应将tabBarController放置在导航控制器中。您需要撤销顺序。您可以通过切换tabBarController的控制器数组并设置一组隐藏tabBar来发挥技巧。但是,现在尝试使用该订单的任何尝试注定会失败—您可以在iOS5.1中使它工作,然后看到它在6、6.1或7中中断。

关于objective-c - UINavigationController内部的UITabBarController中的间隙,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12570087/

10-12 14:31