Табличное представление с пользовательской ячейкой (программно)

До сих пор я раньше создавал пользовательские перья для создания моей ячейки, как я хотел, но на этот раз, высота ячейки изменится от одного до другого так, чтобы я не мог создать перо ячейки фиксированного размера.

Таким образом, я решил создать его программно... Значительно ниже хорошего способа достигнуть его?

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        UILabel *pseudoAndDate = [[UILabel alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,20.0)];
        [pseudoAndDate setTag:1];
        [cell addSubview:pseudoAndDate];
        [pseudoAndDate release];
    }

    CommentRecord *thisRecord = [comments objectAtIndex:[indexPath row]];

    UILabel *label = (UILabel *)[cell viewWithTag:1];
    [label setText:[NSString stringWithFormat:@"%@ | %@",thisRecord.author,thisRecord.date]];

    return cell;
}

или.. я пропускаю что-то здесь? Причина до сих пор это, кажется, не работает ;)

Спасибо,

Gotye.

6
задан casperOne 4 December 2012 в 16:51
поделиться