简体   繁体   English

嵌入在 ViewController 中的 TableViewController

[英]TableViewController embedded in ViewController

Following this answer , I embedded a TableViewController into a container of a ViewController like this:按照这个答案,我将一个 TableViewController 嵌入到一个 ViewController 的容器中,如下所示:

在此处输入图片说明

Now that I've got two ViewControllers (one embedded in another);现在我有两个 ViewControllers(一个嵌入在另一个中); should I create a .swift file (class) for each ViewController, or just one which controls both using some kind of hierarchy?我应该为每个 ViewController 创建一个 .swift 文件(类),还是只使用某种层次结构来控制两者? I also read some answers about delegate and dataSource but applied in cases that weren't exactly like this one.我还阅读了一些关于委托和数据源的答案,但适用于与此不完全相同的情况。

You can do that with both the approaches, I would recommend making two files separately for both controllers.您可以使用这两种方法来做到这一点,我建议为两个控制器分别制作两个文件。

Either way you have to create two classes.无论哪种方式,您都必须创建两个类。 So files wont matter.所以文件无关紧要。

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

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