创建一个包含UIViewController的UIViewController [英] Create a UIViewController that contain a UIViewController

查看:158
本文介绍了创建一个包含UIViewController的UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIViewController ,它允许我在视图中显示一些文本。
我想添加一个输入法而不直接将它添加到这个视图控制器中,这个输入法将是一个按钮或 UITextField
这个输入法将会很多,但它会在设置时使用一个,所以我不会有一个 UIViewController 来控制所有这个。

I have a UIViewController that allow me to display some text into a view. I want to add an input method without add it directly into this view controller, this input method will be a button or a UITextField. This input method will be a lot, but it will be use one at time chosing it from setting so a I won't to have a UIViewController that control all of this.

我想知道如何用每个输入视图(控制器)分割输出视图(控制器)?

What I want is know how it's possible to split the output view (controller) with each input view (controller)?

你可以想象图像在屏幕顶部有一个文本视图,在底部有一些其他视图,我将把第二个视图的逻辑与第一个视图的逻辑分开

You can image to have a text view on the top of the screen and some other view at the bottom and I will to separate the logic of the second view from the logic of the first one

是否清楚?

推荐答案

当然,任何时候都可以在屏幕上显示2个UIViewControllers!有几种方法可以解决这个问题:

Of course it is possible to have 2 UIViewControllers on screen at any time! There are a few ways to go about this:

使用一个主视图:将第二个ViewController的视图添加为子视图

Using One Main View: Add the second ViewController's view as a subview

使用Interface Builder:在UIViewController对象中拖动,设置它的类,然后将它的View插口挂钩到第一个ViewController中的UIView。

Using Interface Builder: Drag in a UIViewController Object, set it's class, then hook it's View outlet to a UIView in the first ViewController.

子视图控制器:As它的名字暗示, - addChildViewViewController:方法也会添加一个新的ViewController,然后将它的视图添加为子视图。

Child View Controller: As it's name implies, the -addChildViewViewController: method will add a new ViewController as well, then add it's view as a subview.

这篇关于创建一个包含UIViewController的UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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