iOS: 在UIViewController 中添加Static UITableView

iOS: 在UIViewController 中添加Static UITableView

若是你直接在 UIViewController 中加入一个 UITableView 并将其 Content 属性设置为 Static Cells,此时 Xcode 会报错:html

Static table views are only valid when embedded in UITableViewController instances.spa

 

 

意思是说,若是 UITableView 不是在 UITableViewController 而是在 UIViewController 中的时候,是不容许将 UITableView 的 Content 属性设置为 Static Cells 的。code

 

可是,若是想让 UIViewController 中的 UITableView 是一个 Static Cells 的怎么办呢?htm

 

方法是有的!既使用Container View在中间链接一下。blog

步骤以下:get

  1. 先将 TableView 放到一个 UITableViewController 中,
  2. 而后在原来的 UITableViewController 加入一个 ContainerView,
  3. 最后链接 ContainerView 和 UITableViewController。

 

 

效果:table

相关文章
相关标签/搜索