将UITableViewController插入其他UIView [英] Insert UITableViewController into Other UIView

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

问题描述

我有一个UITableViewController,它将自定义UITableViewCells插入到UITableView中。有没有办法可以将这个UITableController / View组合放到不同的视图中?我有UITableView的行为按我想要的方式运行,我只是想在不同的UIViews中使用那个UITableView(比如在UITableView上面有UILabel的UIView,在UITableView下面有一个UILabel)。

I've got a UITableViewController that inserts custom UITableViewCells into a UITableView. Is there a way that I can put this UITableController/View combo into different views? I've got the behavior of the UITableView acting the way I want, I just want to use that UITableView in different UIViews (say a UIView with a UILabel above the UITableView and one with a UILabel below the UITableView).

我知道我可以制作一个UIViewController,其中包含一个嵌入式UITableView,并让UIViewController充当UITableView的委托,但后来我会重用代码(UITableViewController逻辑将在多个UIViewControllers中) )。或者我是以错误的方式看待这个问题?

I know I can make a UIViewController that has an embedded UITableView in it and have the UIViewController act as the UITableView's delegate, but then I would have code reuse (the UITableViewController logic would be in multiple UIViewControllers). Or am I looking at this problem the wrong way?

我想以某种方式在不同的UIViews中重用我的UITableView的功能。

I want to somehow reuse the functionality of my UITableView in different UIViews.

谢谢

推荐答案

是的,你可以简单地在UIViewController中实例化(或获取一个)UITableViewController并调用这样的东西:

Yes, you can, simply instantiate (or get a reference to) the UITableViewController inside the UIViewController and call something like this:

[self.view addSubview:tableViewController.tableView];

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

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