gpt4 book ai didi

ios - UIStoryboard 更改标签栏按钮文本

转载 作者:行者123 更新时间:2023-11-29 02:39:38 27 4
gpt4 key购买 nike

我正在像这样用 MainStoryBoard 编写程序。我有带有 5 个选项卡的 UITabBarController。在每个uiviewcontroller的viewdidload中,我是这样设置的。但是,只有当我转到该页面时它才会起作用。所以,我打算在我的 AppDelegate 中为所有选项卡做。我该如何以编程方式进行?我可以在 UIStoryBoard 中设置文本,但我需要以编程方式设置。

self.title = @"Some title";

enter image description here

最佳答案

为此,您应该首先获取 Storyboard实例。然后从 Storyboard获取标签栏。在 AppDelegate 的以下方法中执行此操作。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
UITabBarController *tabBar = [storyBoard instantiateInitialViewController] ;
NSLog(@"%@",tabBar.viewControllers);
// You will get list of your viewcontrollers added to tabbar .Get the instances of those view controllers and set title to them here.
return YES;
}

关于ios - UIStoryboard 更改标签栏按钮文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25947243/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com