2013-04-17 3 views
0

내 cellForRowAtIndexPath : indexPath : 올바른 UITableViewCell을 반환합니다. (나는 그것을 입증 할 수있는 흔적이 없다는 주장을 가지고있다.)UITableView dataSource는 tableView에서 셀을 반환해야합니다. cellForRowAtIndexPath : do do accept

그러나 나는이 산발적 인 예외를 받고있다.

이 내가 셀 재사용/할당하는 방법입니다

... 
{ 
    UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier: cellIdentifier]; 
    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault 
            reuseIdentifier: cellIdentifier] autorelease]; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    } 
    assert(cell); 
    // (code to populate cell) 
    // ... 
    assert(cell != nil); 
    NSLog(@"returning cell %@ type %@", cell, NSStringFromClass([cell class])); 
    // edit: showing actual return value 
    return cell; 
} 

충돌 로그에 다음과 같습니다 : 제가 비슷한 질문에 수많은 다른 항목을 살펴 보았다

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 to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' 

합니다. 나는 곤두박질 친다! 나는 내가 반환 한 셀이 제로가 아니 었는지 확인하고 여전히이 주장을 얻는 숙제를했습니다!

누구든지이 문제를 해결할 수 있습니까? 문제의 dealloc에서 전무로 tableView.datasource 및 tableView.delegate을 할당하여 해결되었다 : (우려까지 cellForRowAtIndexPath로)

감사

+2

'return cell;'호출을 포함한 완전한'cellForRowAtIndexPath'를 보여줍니다. – rmaddy

답변

0

내가 결국 셀을 반환 한 것으로 나타났다.

컨테이너보기 컨트롤러의 할당이 해제 되어도 테이블보기가 여전히 dealloc을 보류하고 있으며 내 cellForRowAtIndexPath 구현을 호출 할 수 없습니다. 적어도 문제 (및 수정 사항)를 재현 할 수있었습니다.