在第一个选项卡加载之前修改(Storyboard)TabBarController选项卡 [英] Modify (Storyboard)TabBarController tabs before the first tab loads

查看:45
本文介绍了在第一个选项卡加载之前修改(Storyboard)TabBarController选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我的应用程序在运行时决定哪些TabBarItems可用.问题是,在实际的TabBarController类中(在viewDidLoad和viewWillAppear中),[self.tabBarController viewControllers]为空.它会在第一个ViewController(选项卡)加载后填充,但是为时已晚,因为我什至不知道是否要加载此特定控制器.

So my app decides at runtime which TabBarItems are available. Problem is, [self.tabBarController viewControllers] is empty in the actual TabBarController class (in viewDidLoad and viewWillAppear that is). It is filled after the first ViewController (tab) did load, but that is too late as i dont even know if i want to load this particular one.

我知道可以通过转储故事板来解决,是否也可以依靠它?

I know this can be solved by dumping storyboard, is it possible relying on it too?

到目前为止,想到的最好的解决方案是创建一个虚拟ViewController,在加载完成后立即将其替换掉...

Best solution that comes to mind so far is creating a dummy ViewController that gets swapped out immediately after loading is done...

推荐答案

它为空,因为选项卡栏控制器没有tabBarController属性.它应该只是self.viewControllers.

It's empty because the tab bar controller doesn't have a tabBarController property. It should just be self.viewControllers.

这篇关于在第一个选项卡加载之前修改(Storyboard)TabBarController选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆