简体   繁体   中英

Insert UITableViewController into Other UIView

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).

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?

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

Thanks

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

[self.view addSubview:tableViewController.tableView];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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