Prototype Cells in a nib instead of a storyboard

前端 未结 2 1104
再見小時候
再見小時候 2020-11-29 18:02

For better re-usability I want to create a table view outside of my Storyboard.

Now when I create a UITableView based ViewController with Nib in Xcode I

2条回答
  •  孤独总比滥情好
    2020-11-29 18:29

    iOS 5 includes a new method on UITableView: registerNib:forCellReuseIdentifier:

    To use it, put a UITableViewCell in a nib. It has to be the only root object in the nib.

    You can register the nib after loading your tableView, then when you call dequeueReusableCellWithIdentifier: with the cell identifier, it will pull it from the nib, just like if you had used a Storyboard prototype cell.

提交回复
热议问题