2011-11-23 304 views
0

繼續我的最後一個問題UITableViewCell custom cell using IB loading data最好爲新問題啓動一個新的問題!UITableCell自定義單元格不佔用自定義單元格的高度

我的自定義單元加載中(在IB設計)

下面是自定義單元格我的XIB文件:

enter image description here

而且繼承人如何加載在我的表:

enter image description here

因此,它不會加載自定義單元格的大小屬性(但它將文本加載到正確的標籤和它的加載右邊的藍色箭頭從筆尖)

代碼繼承人如何填充表:

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

    static NSString *CellIdentifier = @"Cell"; 

    ViewRoutesCell * aCell = (ViewRoutesCell *)[tableView dequeueReusableCellWithIdentifier:@"ViewRoutesCell"]; 

    if (aCell == nil) 
    { 


     NSArray *arr = [[NSBundle mainBundle] loadNibNamed:@"ViewRoutesCell" owner:self options:nil]; 

     for (NSObject *anObj in arr) { 

      if([anObj isKindOfClass:[ViewRoutesCell class]]) { 
       aCell = (ViewRoutesCell *)anObj; 
       aCell.lblRouteText.text = [arryRouteText objectAtIndex:indexPath.row]; 
       aCell.lblRouteImage.text = [arryRouteImage objectAtIndex:indexPath.row]; 
      } 



     } 
} 

    return aCell; 
} 

我在做什麼錯裝電池?

湯姆

+0

只是設置你的tableview的rowHeight屬性 ''[self.tableView setRowHeight:30];'或任何你的身高應該是 – Maggie

回答

3

tableView:heightForRowAtIndexPath:您可能需要這個方法(的UITableView的委託方法)。
只需返回你想要的高度。或者通過indexPath來判斷不同類型的細胞。

+0

它不能只是從xib文件繼承它? – TMB87

+0

@TomBeech,是的,它可以。一般來說,您可以在Interface Builder中設置行高('Inspector'->'Table View Size'->'Row Height')。也許這是'Group' tableView的問題,或者你錯過了什麼。爲什麼不試試? ;) – Kjuly