我像这样创建了一个 UITabBarController:
InfoViewController *iVC = [[InfoViewController alloc] init];
self.infoViewController = iVC; // retain property
UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0];
self.infoViewController.tabBarItem = tabBarItem;
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:myVC];
self.navigationController = nc;
UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostRecent tag:1];
self.navigationController.tabBarItem = tabBarItem;
UITabBarController *tbc = [[UITabBarController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:self.infoViewController, self.navigationController, nil];
self.tabBarController = tbc; // retain property!
self.tabBarController.viewControllers = 控制器;[待定发布];
问题:我看到底部有一个黑色的标签栏和一个白色的内容区域。数组中的第一个视图控制器具有红色背景色。所以它应该显示为红色。
标签栏不显示任何项目,它是空的。
可能是什么问题?我不使用 nib 文件...没有警告,没有错误,没有任何记录到控制台。只需清空标签栏。