2014-03-06 93 views
0

我在故事板中創建了兩個具有正確重用ID的原型。調試器在我的自定義單元格內的各個斷點處停止,但表格視圖仍然顯示空白單元格。是什麼賦予了?UITableViewCell子類顯示爲空

在此先感謝

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

static NSString *CellID = @"CellIdentifier"; 
static NSString *CommentCellID = @"CommentCellIdentifier"; 

// for iOS6+ not specifying forIndexPath:indexPath causes assertion when endUpdates is called 

NSUInteger sectionNumber = [indexPath section]; 
switch (sectionNumber) { 
    case 2: { 

     // Try to dequeue a cell and create one if necessary 
     SDCCommentCell *commentCell = [tableView dequeueReusableCellWithIdentifier:CommentCellID]; 
     if (commentCell == nil) { 
      commentCell = [[SDCCommentCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CommentCellID]; 
      //cell.cellInsetWidth = kSDCCellInsetWidth; 
      commentCell.delegate = self; 
     } 

     PFObject *object = [parseObjectsArray objectAtIndex:indexPath.row]; 

     [commentCell setUser:[object objectForKey:kSDCActivityFromUserKey]]; 
     [commentCell setContentText:[object objectForKey:kSDCActivityContentKey]]; 
     [commentCell setDate:[object createdAt]]; 
     return commentCell; 
    } 
    default: { 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath]; 
     return cell; 
    } 
} 

}

回答

0

沒關係..我只是想通了。我忘了添加在viewDidLoad()

[self.tableView registerClass:[SDCCommentCell class] forCellReuseIdentifier:@"CommentCellIdentifier"];