UITabBar 中的单个选项卡不包含 UINavigationBar
我有一个非常奇怪的问题。我在 UITabBar
中编写了一个带有五个选项卡的应用程序。当我设置 TabBarController 的 viewControllers
属性时,我设置了五个 UINavigationControllers
,这样每个选项卡中都会有一个 UINavigationController
。
其中四个选项卡可以完美运行。当我启动并切换到该选项卡时,导航栏就在那里。但是,其中一个选项卡并不包含我期望的 UINavigationBar,我无法理解为什么,因为我初始化它的方式与初始化所有其他选项卡的方式完全相同。
以下是 AppDelegate.m
文件中用于初始化各个视图控制器的一些示例代码:
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 已在上面声明。
其他人以前遇到过这个问题吗?或者有人知道为什么会发生这种情况?非常感谢任何帮助。谢谢!
I'm having a really strange issue. I've written an app with five tabs in a UITabBar
. When I set the TabBarController's viewControllers
property, I set it with five UINavigationControllers
, so that each tab will have a UINavigationController
within it.
Four of the tabs have it working perfectly. The navigation bar is there when I launch and switch to that tab. However, one of the tabs does not contain the UINavigationBar
as I expected it to, and I can't understand why, because I initialized it exactly the same way I initialized all the others.
Here's some sample code from the AppDelegate.m
file of initializing the individual view controllers:
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];
Note: navigationController was declared above.
Anyone else run into this problem before? Or anyone have any idea why this might be happening? Any help is much appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是你正在这样做:
而不是这样:
The problem is that you are doing this:
instead of this: