我遇到了一个非常奇怪的问题。我在 UITabBar
中编写了一个包含五个选项卡的应用程序。当我设置 TabBarController 的 viewControllers
属性时,我为它设置了五个 UINavigationControllers
,这样每个选项卡中都会有一个 UINavigationController
。
其中四个选项卡完美运行。当我启动并切换到该选项卡时,导航栏就在那里。但是,其中一个选项卡不包含我预期的 UINavigationBar
,我不明白为什么,因为我初始化它的方式与初始化所有其他选项卡的方式完全相同。
下面是 AppDelegate.m
文件中初始化各个 View Controller 的一些示例代码:
SpotFilterViewController *spotList = [[SpotFilterViewController alloc] init];
navigationController = [[UINavigationController alloc] initWithRootViewController:spotList];
[tabs addObject:navigationController];
[navigationController release];
[spotList release];
MySpotViewController *mySpot = [[MySpotViewController alloc] initWithSpot:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:mySpot];
[tabs addObject:mySpot];
[navigationController release];
[mySpot release];
注意:navigationController 是在上面声明的。
以前有其他人遇到过这个问题吗?或者有人知道为什么会这样吗?任何帮助深表感谢。谢谢!
最佳答案
问题是你这样做:
[tabs addObject:mySpot];
而不是这个:
[tabs addObject:navigationController];
关于iphone - UITabBar 中的单个选项卡不包含 UINavigationBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8888509/