我通过代码添加了一个 UINavigationController,但它在顶部留下了一个间隙.. 大约 20 px ..
如果我切换到其他选项卡并返回此选项卡,它会消失,但是在导航栏移动到正确位置之前大约 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 设置为第一次显示(我将其放在第一个选项卡上),则间隙不存在,但如果我将其放在第二个选项卡上,它会显示我是否切换到查看 Tab3。