简体   繁体   English

如何为iOS应用创建自定义容器视图?

[英]How do I create a custom container view for an iOS App?

I am starting out developing an iPad App, and I would like for there to be a toolbar bar at the top that will present different views beneath it as pictured below: 我正在开始开发iPad App,我希望顶部有一个工具栏,在其下方将显示不同的视图,如下图所示: 基本布局

So when each button is pressed, the toolbar should remain in place and different view controller should present its view in that space. 因此,当按下每个按钮时,工具栏应保留在原处,并且其他视图控制器应在该空间中显示其视图。 I read through Apples ViewController programming guide, and it seems like this is possible, but I just somehow didn't get the actual methods that I needed to get a view controller to display its view inside that bottom rectangle. 我通读了《 Apples ViewController编程指南》,这似乎是可行的,但是我却以某种方式没有获得所需的实际方法,而该方法需要一个视图控制器才能在底部矩形内显示其视图。

Is it reasonable to have a container view which manages the toolbar, and then creates a view controller to display a sub view within that lower rectangle? 拥有一个管理工具栏的容器视图,然后创建一个视图控制器以显示该下部矩形内的子视图是否合理?

EDIT: 编辑:

I would like to do something along these lines: 我想按照以下方式做一些事情:

-(IBAction)hitMapButton{
    MapViewController *mapView = [[MapViewController alloc] initWithNibName:@"MapView" bundle:nil];
    [self addChildViewController:mapView];
    [mapView release];
}

But I can't figure out how to actually get the view to draw? 但是我不知道如何实际绘制视图?

Search the Apple documentation with 'Creating a Tab Bar'. 使用“创建标签栏”搜索Apple文档。 You'll find several documents: creating programmatically, creating with segue, etc. There are also a number of sample projects that you can view based on that search, for example 'Tabster' (an iPhone app that is a bit dated but will certainly help you - edit the target to be 'iPad'). 您会找到几个文档:以编程方式创建,使用segue创建等。您还可以基于该搜索查看许多示例项目,例如“ Tabster”(一种过时的iPhone应用程序,但肯定会帮助您-将目标设置为“ iPad”)。

You can get a working staring point by creating a new Xcode project and selecting 'Tabbed Application' 通过创建一个新的Xcode项目并选择“ Tabbed Application”,您可以得到一个有效的凝视点。

Note that the UITabBarController puts the tab bar at the bottom - if you are thinking about putting it at the top you should also read the 'User Experience Guidelines' 请注意,UITabBarController将选项卡栏放在底部-如果您正在考虑将其放在顶部,则还应该阅读“用户体验指南”

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

相关问题 如何在容器视图单元中创建地图视图 - How do I create a Map View in Container View Cell iOs-使用容器,表视图和详细视图-如何在容器中保留详细视图 - iOs - Using container, table view and detailed view - How do I keep detailed view inside container 如何为iOS应用程序创建带有动画的自定义视图或控件? - How to create custom view or control with animation for iOS app? 如何创建自定义 iOS 视图类并实例化它的多个副本(在 IB 中)? - How do I create a custom iOS view class and instantiate multiple copies of it (in IB)? 如何创建自定义iOS视图 - How to create custom iOS View 调试 iOS 应用时如何查看 App Group Shared Container 目录的内容? - How can I view the contents of the App Group Shared Container directory when debugging an iOS app? 如何将我的 iOS 应用程序的默认联系人容器设置为保存在 iCloud 中的联系人容器? - How do I set the default contacts container for my iOS app to the contacts container that is saved in iCloud? 如何为IOS iPhone应用程序循环播放多个视图控制器? - How do I loop multiple view controllers for an IOS iphone app? 如何在iOS应用中显示密码视图 - How do I show a passcode view in an iOS app 如何在 iOS 13/14 中的应用程序顶部添加视图 - How do I add a view to the top of an app in iOS 13/14
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM