2013-03-31 3 views
0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"LibraryListingCell"; 

    InSeasonCell *cell = (InSeasonCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     [[NSBundle mainBundle] loadNibNamed:@"InSeasonCellView" owner:self options:nil]; 
     cell = [_cell autorelease]; 
     _cell = nil; 
    } 
    if(_dataController!=NULL){ 
     Product *productAtIndex = [_dataController objectInListAtIndex:indexPath.row]; 
     // Configure the cell... 
     if (productAtIndex.name != nil && productAtIndex.week != nil && productAtIndex.image != nil) { 
      cell.name.text = productAtIndex.name; 
      cell.week.text = productAtIndex.week; 
      cell.image.image = productAtIndex.image; 
     } 
    } 

    return cell; 
} 

메시지 오류 cell.name.text의 cell.week.text의 cell.image.text합니다. 확실히 그것은 메모리 관리 오류입니다. 나는 최선을 다해 적절히 유지하고 배포했다. 응용 프로그램이 실행될 때 충돌이 발생하고 때로는 모든 것이 제대로로드되지만 스크롤하면 충돌이 발생합니다. 메모리 관리에 대한 도움이나 조언을 주시면 감사하겠습니다. 대신이의아이폰 OS : lldb EXC_BAD_ACCESS 사용자 정의 셀

답변

3

는 :

if (cell == nil) { 
    [[NSBundle mainBundle] loadNibNamed:@"InSeasonCellView" owner:self options:nil]; 
    cell = [_cell autorelease]; 
    _cell = nil; 
    } 

나중에 당신이 cell을 발표 액세스하려고하는, 오토 릴리즈 메시지를 보내 전무로 설정합니다.

이 나는대로해야한다고 생각 :

static NSString *CellIdentifier = @"LibraryListingCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

if (cell == nil){ 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
} 
+0

_cell 사용자 지정있는 UITableViewCell은 내가 함께 IBOutlet로 액세스 할 수 있습니다. Idon't는 내가 IBOutlet를 해제해야하거나, 1를 할당해야한다라고 생각한다. IBOutlet을 공개하지 않고 사용하려고합니다. – wwjdm

+0

이 자습서는 http://www.iphonedevcentral.com/customize-that-uiviewcell-part-1-using-interface-builder/에서 사용했습니다. – wwjdm

+0

사용자 지정 셀 .h .m 및 xib 파일이 있습니다. 어떻게 새로운 UITableViewCell을 만들지 않고 (사용자 정의 xib)로드할까요 – wwjdm

관련 문제