我有以下代碼,它爲UITableViewCell繪製分隔線和文本。它看起來很好,但當我滾動屏幕然後返回時,分隔線已消失,但文本仍然正常。有任何想法嗎?重複使用UITableViewCell問題
static NSString *aProgressIdentifier = @"CustomerCell";
UITableViewCell *aCustomerCell = [iTableView dequeueReusableCellWithIdentifier:aProgressIdentifier];
if (!aCustomerCell) {
aCustomerCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:aProgressIdentifier] autorelease];
aCustomerCell.contentView.backgroundColor = [UIColor whiteColor];
UIImageView *aLine = [[UIImageView alloc] initWithFrame:CGRectMake(0, 72, 800, 1)];
aLine.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
[aCustomerCell addSubview:aLine];
[aLine release];
}
CMACustomer *aCustomerObject = aCellObject;
aCustomerCell.textLabel.text = aCustomerObject.customerFullName;
aCustomerCell.detailTextLabel.text = nil;
aCell = aCustomerCell;
雅的高度恰好是72,並且該線最初顯示,這意味着它的工作原理。我試過你發佈的第二個代碼,但它只給我所有沒有文本或任何東西的灰色單元格。 – Jon 2012-02-21 21:16:27
我實際上已將行改爲71,現在所有作品。奇怪。 – Jon 2012-02-21 21:39:19