在其他视图中更改 UItabbaritem 的标题?

发布于 2024-09-11 09:44:24 字数 209 浏览 1 评论 0原文

启动应用程序时如何更改 UITabbaritem 标题?

我有一个带有 4 个选项卡的 UITabBar。我希望用户能够在两种不同的语言之间进行更改。如果用户选择不同的语言,我需要为 UITabbaritems 设置不同的标题。我知道我可以使用 self.title = @"title"; 但这只会更改当前的 tabbaritem 标题。如何在加载时以及选择不同语言时立即更改所有标题?

How do I change the UITabbaritem titles when starting the App?

I got a UITabBar with 4 tabs. I want the user to be able to change between two different languages. If the user chooses a different language I need to set a different title to the UITabbaritems. I know I can use self.title = @"title"; but that only changes the current tabbaritem title. How can I change all the titles at once, on load, and when choosing a different language?

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

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

发布评论

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

评论(2

长途伴 2024-09-18 09:44:24

我遇到了同样的问题并解决了它。

[[self.tabBarController.viewControllers objectAtIndex:index] setTitle:@"Your title"];

其中 index 是您的 UITabBarItem 索引。

I got the same problem and solved it with.

[[self.tabBarController.viewControllers objectAtIndex:index] setTitle:@"Your title"];

Where index is your UITabBarItem index.

勿忘心安 2024-09-18 09:44:24

您需要将所有 UITabBarItem 存储到一个数组中,当用户点击按钮时,您需要循环遍历该数组并设置标题。

for (UITabBarItem *item in items) {
  item.title = @"WHATEVER HERE";
}

You need to store all your UITabBarItem into an array, when the user tap the button, you need to loop through that array and set the title.

for (UITabBarItem *item in items) {
  item.title = @"WHATEVER HERE";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文