ios - UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath: but I do -
i dont understand this: cellforrowatindexpath: indexpath: returns proper uitableviewcell. (i have assertion effect not nil , trace prove it)
but stil getting sporadic exception?
this how allocate / reuse cell:
... { uitableviewcell *cell = [tv dequeuereusablecellwithidentifier: cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithstyle: uitableviewcellstyledefault reuseidentifier: cellidentifier] autorelease]; cell.selectionstyle = uitableviewcellselectionstylenone; } assert(cell); // (code populate cell) // ... assert( cell != nil); nslog(@"returning cell %@ type %@", cell, nsstringfromclass([cell class])); // edit: showing actual return value return cell; }
the crash looks in log:
2013-04-17 16:46:05.323 .. -[someeditviewcontroller tableview:cellforrowatindexpath:] returning cell <uitableviewcell: 0x20d1a2e0; frame = (0 351; 320 43); hidden = yes; autoresize = w; layer = <calayer: 0x20d1a410>> type uitableviewcell 2013-04-17 16:46:15.296 ... *** assertion failure in -[uitableview _configurecellfordisplay:forindexpath:], /sourcecache/uikit/uikit-2380.17/uitableview.m:5471 2013-04-17 16:46:15.301 ... *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'uitableview datasource must return cell tableview:cellforrowatindexpath:'
i have looked @ numerous other entries similar question. stumped! did homework, ensuring cell returned not nil, , still assertion!
anyone can this? thanks
it turns out did return cell after (as far cellforrowatindexpath: concerned)
the problem solved assigning tableview.datasource , tableview.delegate nil in dealloc.
the table view still pending dealloc when container view controller deallocated, , not call cellforrowatindexpath implementation. @ least, able reproduce problem (and fix).
Comments
Post a Comment