Как я могу удалить / отрегулировать заполнение ячейки / поля UITableViewCell? - PullRequest
0 голосов
/ 22 июля 2011

Я использую код ниже; это работает, но текст отображается с отступом / полем в несколько пикселей.

Как я могу удалить / отрегулировать отступы / поля для ячеек?

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

1 Ответ

0 голосов
/ 22 июля 2011

Используйте пользовательскую ячейку:

- (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;

}
...