简体   繁体   English

向故事板中的选项卡栏控制器场景添加按钮

[英]Add a button to tab bar controller scene in storyboard

I am trying to design a application that has a tab bar on the bottom and two buttons on the top of the screen. 我正在尝试设计一个应用程序,该应用程序的底部具有标签栏,屏幕顶部具有两个按钮。

在此处输入图片说明

However, I'm not able to drag a UI Button onto the Tab Bar Controller Scene in storyboard on Xcode. 但是,我无法将UI按钮拖到Xcode故事板上的选项卡栏控制器场景上。 I'm able to add buttons, search bars, etc to the view controller of each tab bar item, but not the original home screen. 我能够将按钮,搜索栏等添加到每个选项卡栏项的视图控制器,但不能添加到原始主屏幕。 Why is that? 这是为什么?

The UITabBarController is a view controller, but it's really just a container for other view controllers, one per tab. UITabBarController是一个视图控制器,但实际上它只是其他视图控制器的容器,每个选项卡一个。 If you want things to appear on all of your tabs (like the two buttons you show at the top), you have to add them to each of your sub-view controllers. 如果希望所有选项卡上显示所有内容(如顶部显示的两个按钮),则必须将它们添加到每个子视图控制器中。 (Ideally, you'd do this once in a superclass, which each of your tabs' view controllers will implement, but that may not fit your needs.) (理想情况下,您将在超类中执行一次此操作,每个选项卡的视图控制器都将实现该超类,但这可能无法满足您的需求。)

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

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