我创建了一个像这样的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 =控制器; [TBC版本];

问题:我在底部和一个白色内容区域看到一个黑色标签栏。数组中的第一个视图控制器具有红色背景颜色。因此它应该显得红色。

标签栏不显示项目,它是空的。

有什么问题?我不使用笔尖文件...没有警告,没有错误,没有记录到控制台的情况。只需空标签栏即可。

有帮助吗?

解决方案

您不是缺少:

self.tabBarController.viewControllers = controllers;

编辑:

除此之外,我在随附的代码中看不到任何错误的东西,所以这使我认为其他事情必须是错误的。一些选项:

  1. 您确定self.tabbarcontroller指向任何东西(不是零)吗?
  2. 您确定它指向您看到的同一uitabController吗?
  3. 您确定要创建的控制器是否正确创建?尝试显示它们,无论塔巴尔如何

    self.tabbarcontroller rastryModalViewController:IVC动画:是];

  4. UitabController是由笔尖创建的吗?如果将其放在initwithnibname或Awakefromnib上,以确保在您的代码之前调用它,并且在代码后不再调用。

首先,如果没有任何迹象表明其他问题出了问题,我可以想到还有一些尝试。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top