appzYourLife appzYourLife - 1 year ago 73
Swift Question

Same prototype cell with multiple UITableView(s)

In Storyboard I can define one (or more) prototype cell(s) to be used with a


However I'd need to use the same prototype cell with multiple UITableView(s)?

Is it possible?

Answer Source

The only way to share a cell across UITableView's is to define them in an .xib as a separate file and give them a reuse identifier. Then in code register that file / corresponding class to the UITableView.

e.g. place this inside the viewDidLoad() of your tableViewController:

tableView.registerNib(UINib(nibName: "", bundle: NSBundle.mainBundle()), forCellReuseIdentifier: "")

And then you can continue on as normal inside the cellForRowAtIndexPath