我正在这样用MainStoryBoard编写程序。我有5个标签的UITabBarController。在每个uiviewcontroller的viewdidload中,我这样设置。但是,只有在我转到该页面时,它才会起作用。因此,我计划在AppDelegate中为所有选项卡进行操作。我该如何编程?我可以在UIStoryBoard中设置文本,但是我需要以编程方式进行设置。
self.title = @"Some title";
最佳答案
为此,您应该首先获得情节提要实例。然后从故事板上获取标签栏。使用以下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/