我通过代码添加了一个 UINavigationController,但它在顶部留下了一个空隙……大约 20 像素……
如果我切换到其他选项卡并返回到此选项卡,它会消失,但在 NavBar 移动到正确位置之前大约 0.2 秒可以看到它。
我已经在 StackOverflow 上搜索了,但找不到解决方案...
这是我的代码的一部分:
appDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
.....
UIViewController *vc1 = [[Tab1 alloc] initWithNibName:@"Tab1" bundle:nil];
UIViewController *vc2 = [[FreshEpisodeController alloc] initWithNibName:@"FreshEpisodeController" bundle:nil];
UIViewController *vc3 = [[Tab3 alloc] initWithNibName:@"Tab3" bundle:nil];
UIViewController *vc5 = [[DownloadListController alloc] initWithNibName:@"DownloadListController" bundle:nil];
self.tabBarController = [[UITabHost alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:vc2, vc1, vc3, vc5, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
.....
}
Tab3.m
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[[self view] addSubview:mNavController.view];
self.title = NSLocalizedString(@"Collection List", @"Collection List");
self.tabBarItem.image = [UIImage imageNamed:@"tab3"];
}
return self;
}
在 Tab3.xib 中,我有一个 UIView
和 UINavigationController
(mNavController)
如果我设置 Tab3 在第一时间显示(我把它放在第一个标签),那么差距就没有了 但是如果我把它放到第二个选项卡,它会显示我是否切换到 View Tab3。
最佳答案
在 ViewController 的 Attributes 部分将 Under Top Bars 属性设置为未选中可能会有所帮助。 p>
关于ios - UINavigationController 顶部有一个空隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10715386/