2011-07-22 9 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と指定します。 –

関連する問題