iPhone/iPad 上的一个屏幕上有多个视图?
我想在屏幕顶部构建自定义选项卡菜单,类似于您在 Numbers 应用程序中看到的菜单。 我想我可以将屏幕划分为两个视图:一个位于顶部用于选项卡,另一个较大用于选定的选项卡视图。 这可能吗?我可以有 2 个活动视图和视图控制器吗?
I would like to build custom tab menu on top of the screen, similar to one you see in Numbers app.
I thought I could divide screen beetween two views: one on top for tabs and one bigger for selected tab view.
Is that possible? Can I have 2 active views&view controllers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然有可能。您可以将视图控制器中的视图添加为当前根视图控制器视图的子视图。
这样做(假设这是在 UIViewController 子类中):
完全没问题。
但还要考虑您是否真的需要多个视图控制器而不仅仅是额外的视图。根据我从您的描述中得到的信息,我认为它可以仅使用一个带有附加视图的视图控制器来实现。
关于您的选项卡式菜单实现,不 UITabBarController 满足您的需求吗? iOS 应用程序中的选项卡式界面更常见的是使用这种选项卡栏,而不是选项卡位于顶部的桌面操作系统选项卡栏。
Of course it is possible. You can add views from view controllers as a subview of your current root view controller's view.
Doing this (assume this is inside a UIViewController subclass):
is perfectly fine.
But also consider if you really need multiple view controllers and not just additional views. From what I get from your description, I think it can be implemented with just one view controller with additional views.
Regarding your tabbed menu implementation, doesn't UITabBarController fit your needs? It is more common for tabbed interfaces in iOS apps to use this kind of tab bar, not the desktop OS tab bar where the tabs are at the top.
正如我从各种来源获得的那样,视图控制器旨在控制占用应用程序窗口的一个视图,因此使用多个视图执行选项卡式菜单是不可能的。
可能有以下可能性:
有人有更好的想法吗?
As I could get from variety of sources, view controller is meant to control one view that occupies application window, so doing tabbed menu with multiple views is not possible.
There may be folowing possibilities:
Does anybody have any nicer idea?
试试这个:
Try this: