6

以前はカスタムペン先を作成してセルを自由に作成していましたが、今回はセルの高さが変化するため、固定サイズのセルのペン先を作成できません。

それで私はそれをプログラムで作成することに決めました...それを達成するための良い方法の下の方法はありますか?

// 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;
}

または..私はここで何かが欠けていますか?これまでのところ、うまくいかないようです;)

ありがとう、

ゴティエ。

4

3 に答える 3

0

高さがセルごとに異なることが問題である場合は、次の方法を使用できます。

https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITableViewDelegate/tableView:heightForRowAtIndexPath :

UITableViewDelagate からそれを達成する

于 2013-11-10T23:28:35.327 に答える