【发布时间】:2011-02-01 12:24:23
【问题描述】:
到目前为止,我过去常常创建自定义笔尖来制作我想要的单元格,但这次,一个单元格的高度会从一个变为另一个,因此我无法创建一个固定大小的单元格的笔尖。
所以我决定以编程方式创建它...下面的方法是实现它的好方法吗?
// 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;
}
或者..我在这里错过了什么吗?因为到目前为止它似乎不起作用;)
谢谢,
哥蒂。
【问题讨论】:
标签: uitableview row customization cell reusability