0

我正在使用下面的代码;它可以工作,但文本出现时左填充/边距只有几个像素。

如何删除/调整单元格填充/边距?

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

1 回答 1

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;

}
于 2011-07-22T05:02:37.393 回答