UITabBarController 中的错误?

发布于 2024-09-24 00:22:19 字数 259 浏览 4 评论 0原文

我身上发生了一些非常奇怪的事情。我已经反复检查过自己。 我正在使用 UITabBarController,并使用 4 个不同的视图控制器对其进行初始化。 但是,由于某种原因,当应用程序启动时,仅显示第一个标签栏图像。只有当我触摸选项卡栏的空白部分时,底层图像才会突然出现。
我怀疑这是最新 SDK 中引入的错误 - 我刚刚使用 iOS SDK 4.1 更新到 Xcode 3.2.4。 其他人也发生过这种情况吗? 或者也许 - 知道什么可能导致这种情况吗?

谢谢!
爱丽儿

Something very strange is happening to me. I've been double and triple checking myself.
I'm using a UITabBarController, and initializing it with 4 different view controllers.
However, for some reason, when the application starts, only the first tab bar image is displayed. It's only when I touch the blank part of the tab bar - then the underlying image suddenly appears.
I suspect it's a bug introduced in the latest SDK - I've just updated to Xcode 3.2.4 with iOS SDK 4.1.
Has this happened to anyone else?
Or perhaps - any idea what could cause this?

Thanks!
Ariel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゞ花落谁相伴 2024-10-01 00:22:19

我发现了我的问题。这不是新 Xcode 版本中的错误,这当然是我自己的错误,感谢你们的帮助。

问题是我正在各种视图控制器的 viewDidLoad 函数中初始化 UITabBarItems。但是,此函数仅针对第一个视图控制器(正在显示的视图控制器)调用,并且在我触摸相关选项卡栏按钮之前不会为所有其他视图控制器调用。因此,仅当触摸按钮时,选项卡栏项目才会初始化并出现。

解决方案是在 UIViewController 的 init 函数中初始化 UITabBarItems。
现在一切正常:-)

再次感谢大家!
爱丽儿

I found my problem. It wasn't a bug in the new Xcode version, it was my own mistake of course, and thank you guys for trying to help.

The problem was I was initializing my UITabBarItems in the viewDidLoad function of the various view controllers. However, this function was invoked only for the first view controller (the one being displayed) and wasn't invoked for all other view controllers until I touched the relevant tab bar button. And therefore, only when touching the button, the tab bar item was initializing and appearing.

The solution was to initialize the UITabBarItems in the init function of the UIViewController.
Now it all works just fine :-)

Thanks again guys!
Ariel

夏至、离别 2024-10-01 00:22:19

我的回答完全是为了后代。

放入 -(id)init 中对我不起作用...

但是,将其放入 (void)awakeFromNib 中却可以,因为:

1) init 未被调用如果正在加载与 UITabBarController 的笔尖连接...
2) awakeFromNib 在加载时被调用:)

My answer is strictly for posterity.

Putting in in -(id)init didn't work for me...

HOWEVER, putting it in (void)awakeFromNib did because:

1) init isn't called if the nib connections to a UITabBarController are being loaded...
2) awakeFromNib IS called when it is loaded :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文