I have to show 2 different cells in a table. I have tried it by setting a prototype to a table. but it is still showing Prototype table cells must have reuse identifiers>
You must set the Reuse Identifier
for both prototype cells, and they must be different. Then in your cellForItemAtIndexPath
method, you must dequeue the cells using the corresponding Reuse Identifier
based on the indexPath given.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableView {
switch indexPath.section {
case 0:
return tableView.dequeueReusableCellWithIdentifier("CustomCell1", forIndexPath: indexPath)
case 1:
return tableView.dequeueReusableCellWithIdentifier("CustomCell2", forIndexPath: indexPath)
break:
return UITableViewCell()
}
}