UIViewController里面的UITableViewController [英] UITableViewController inside a UIViewController

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

问题描述

我是iOS和Objective-C的新手,我在理解控制器如何工作方面遇到了一些麻烦。



在我的代码中我有一个UIViewController(带有我的自定义控制器由storyboard分配)并在其中与其他对象一起,我希望有一个由不同控制器处理的表。这样做的正确方法是什么?

解决方案

您可以将该表视图控制器设置为UIViewController的子视图控制器。在故事板中,您可以通过将容器视图拖动到控制器的视图中来轻松完成此操作,这将自动为您提供子视图控制器。您将要删除它为您提供的控制器(它只是一个UIViewController),拖出一个表视图控制器,控制从容器视图拖动到表视图控制器,然后选择嵌入。如果你需要从UIViewController获取对这个表视图控制器的引用,你可以在prepareForSegue中执行 - 表视图控制器将是segue的目标视图控制器,并且在实例化控制器之后将立即调用prepareForSegue。 p>

I'm new to iOS and objective-C and I'm having some trouble in understanding how controllers work.

In my code I have a UIViewController (with my custom controller assigned by storyboard) and inside it, together with other objects, I want to have a table handled by a different controller. What is the right way to do this?

解决方案

You can make that table view controller a child view controller of your UIViewController. In the storyboard, you can do this easily by dragging a container view into your controller's view, and that will give you a child view controller automatically. You'll want to delete the controller it gives you (it's just a UIViewController), drag out a table view controller, control drag from the container view to the table view controller, and choose "embed". If you need to get a reference to this table view controller from the UIViewController, you can do that in prepareForSegue -- the table view controller will be the segue's destination view controller, and prepareForSegue will be called right after the controllers are instantiated.

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

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