vendredi 5 décembre 2014

Exception caused by custom cells: UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:


Vote count:

0




I got the following exception:


Fatal Exception: NSInternalInconsistencyException UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:


My tableview has custom cells. Usually this code works. However, the exception happened only once.



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

// Get the cell to populate
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"appt"];

if (!cell) {
// Create new cell
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"appt"];

// Populate from NIB
UINib* nib = [UINib nibWithNibName:@"ScheduledRowView" bundle:nil];
NSArray* views = [nib instantiateWithOwner:nil options:nil];
UIView* parent = [views objectAtIndex:0];
CGRect rowRect = parent.frame;
rowRect.size.width = tableView.frame.size.width;
parent.frame = rowRect;
cell.frame = rowRect;
[cell addSubview:parent];
}

// Populate the cell
// Code for populating cell..

return cell;
}


asked 1 min ago

Carl

11






Exception caused by custom cells: UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:

Aucun commentaire:

Enregistrer un commentaire