简体   繁体   English

使用情节提要板时修改UITabBarController

[英]Modify UITabBarController while using Storyboards

I am a little newer at storyboarding. 我在情节提要上较新。 I have a UITabBarController in my story board as the entry point in my application. 我的故事板上有一个UITabBarController作为应用程序的入口。 I tied all the other view controllers to the tab bar controller. 我将所有其他视图控制器绑定到选项卡栏控制器。 Everything works perfectly fine. 一切正常。 I now want to do some very basic interface, colors, opacity, text, images, etc. 我现在想做一些非常基本的界面,颜色,不透明度,文本,图像等。

This may sound like a very basic question but how can I access my UITabBarController to be able to set my values. 这听起来像是一个非常基本的问题,但是我该如何访问UITabBarController来设置我的值。 What is he best place to be doing these modifications: appDelegate since that one tabbarcontroller controls all of the controllers for the entire app? 做这些修改的最好方法是什么:appDelegate,因为一个tabbarcontroller控制整个应用程序的所有控制器吗?

What I have tried already I created a new class as UITabBarController and I tied it to the UITabBarController in the StoryBoard by setting it as a custom class. 我已经尝试过的操作已经创建了一个新类UITabBarController,并将其设置为自定义类,从而将它绑定到StoryBoard中的UITabBarController。 I couldn't figure out how to access the UITabBarController to make any customizations. 我不知道如何访问UITabBarController进行任何自定义。

You should be able to get the controller using something like: 您应该能够使用类似以下内容的控制器:

AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
UITabBarController *tbc = (UITabBarController *)[[appDelegate window] rootViewController];

(Adding code to test that it really is a UITabBarController before using it would be a good idea.) (在使用它之前添加代码以测试它确实是UITabBarController会是一个好主意。)

Alternatively, if your tab bar controller is a custom sub-class of UITabBarController , it would be cleaner to use its viewDidLoad to modify its own properties. 另外,如果选项卡栏控制器是UITabBarController的自定义子类,则使用其viewDidLoad修改其自身的属性会更加viewDidLoad

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM