2011-07-22 82 views
0

我使用下面的代碼;它可以工作,但是文本顯示只剩下幾個像素填充/邊距。如何刪除/調整UITableViewCell的單元格填充/邊距?

如何刪除/調整單元格填充/邊距?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [resultaterTableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    cell.textLabel.text = [resultater objectAtIndex:indexPath.row]; 
} 

回答

0

使用自定義單元格:

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

    static NSString *CellIdentifier = @"Custom"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 

     UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:cellFrame reuseIdentifier:CellIdentifier] autorelease]; 

    } 

      CGRect *customframe = CGRectMake(2, 2, 250, 30); **// Set the frame** as per your own. 
      UILabel *lbl = [[UILabel alloc] initWithFrame:customframe]; 
      lbl.text = [resultater objectAtIndex:indexPath.row]; **// Set the label value from array** 
      [cell.contentView addSubview:lbl]; 
      [lbl release]; 
return cell; 

} 
+3

這無助於增加保證金周圍的細胞或增加其高度。 –

+0

這個答案指出,如果我們需要填充,我們必須定製單元格的內容視圖。在這種情況下,他添加一個標籤並指定左側和頂部的邊距爲2pt。 –

相關問題