更新时间:2023-11-17 13:40:34
真正简单的解决方案是:
The really simple solution is to:
UITableViewDelegate
和 UITableViewDataSource
,就像 UITableViewController
一样.还要添加一个 UITableView
插座.UITableView
放在视图控制器的视图中.UIViewController
tableView
插座UITableView
的委托和数据源连接到文件的所有者(实现正确委托的自定义 UIViewController
)UITableViewDelegate
and UITableViewDataSource
just like UITableViewController
does. Also add a UITableView
outlet.UITableView
inside the view controller's view.tableView
outlet in your custom UIViewController
UITableView
's delegate and datasource to the File's Owner (your custom UIViewController
that implements the right delegates)您现在拥有一个自定义视图控制器,它的工作方式与 UITableViewController
类似,但您可以完全控制它的布局.您以相同的方式实现委托.
You now have a custom view controller that works just like a UITableViewController
except you have total control over it's layout. You implement the delegates in the same way.