我有一個包含UITabBarController的UINavigationController的根視圖。標籤欄控制器有兩個簡單的視圖。當它首次在iOS 6模擬器或設備上啓動時,第一個視圖上方會出現間隙。切換到第二個標籤並返回,導致間隙消失。這只是從iOS 6開始發生。iOS 5的工作很好。任何想法改變了?UINavigationController中的UITabBarController的差距
截圖:
- (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;
}
爲什麼不使用故事板? – Bernat
剛剛遇到這個我自己看到的問題只存在於ios 7中而不是ios 8.所以蘋果一定意識到這是一個合法的bug,並且將它自己固定在ios 8中 –