如何动态更改标签栏项目的标签(iPhone dev)
我正在使用 XCode 4.1 并且我已经有一个 iPhone 应用程序。
在“MainWindow.xib”的界面构建器中,有一个导航控制器。其中有一个带有标题的选项卡栏项目。我需要动态更改这个标题。但是,似乎没有与 MainWindow.xib 关联的“.h”文件,因此我不知道如何访问该对象。有什么想法吗?
I'm using XCode 4.1 and I have an already existing IPhone app.
In the "MainWindow.xib", in the Interface builder, there is a Navigation Controller. Inside it, a Tab Bar Item with a title on it. I need to change this title dynamically. However, there seems to be no ".h" file associated with the MainWindow.xib, so I have no idea how to access this object. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要 .h 文件来访问 MainWindow.xib 中的项目。您可以在应用程序委托中为要访问的项目声明 IBOutlet。 MainWindow.xib 中的对象之一是应用程序委托,因此您可以将 elementos 分配给其 IBOutlet。
You don't need a .h file to access items in MainWindow.xib. You can declare IBOutlets in your app delegate for the items you want to access. One of the objects in MainWindow.xib is the app delegate, so you can assign elementos to its IBOutlets.
主窗口或选项卡栏 bontroller 在某种程度上与另一个控制器相关(与 .h 和 .m 文件关联)。
因此,在这个控制器中,我添加了以下代码:
对于另外 2 个控制器,依此类推(将索引“0”更改为“1”和“2”);
NSLocalizedString
函数转到本地化文件 (Localized.strings
) 并根据键选择正确的文本。您也可以在那里使用标准字符串。The main window or the tab bar bontroller was, somehow, related to another controller (associated with a .h and .m file).
So in this controller, I added this code :
and so on for the 2 others (changing the index "0" for "1" and "2");
the
NSLocalizedString
function goes to a localized file (Localizable.strings
) and chooses the right text based on the key. You can also just use a standard string there.