Quote:
Originally Posted by dana0550
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
return cell0;
}
if (indexPath.row == 1) {
return cell1;
}
return cell2;
}
I am getting this error:
UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:
According to the apple docs this is basically the way to do it. Everything is connected in IB. Any suggestions on what else I should check for?
Thanks,
Dana
|
No, that's not right.
The method tableView:cellForRowAtIndexPath should do the following (in pseudocode)
Code:
Use the row/section to figure out what type of cell to set up
Check for a recycled cell of that type using dequeueReusableCellWithIdentifier
If no recycled cell is available:
{
create a new, empty cell
Add any custom subviews or "structural" elements to this cell
}
Now set ALL values for a cell of this type, even if the value for this indexPath is the default
return the cell we just dequeued/created