我正在访问一个自定义复选框,我已经在我的项目中使用了自定义按钮,并试图在我的表格视图单元格中访问它。UITableView被滚动后更新自定义按钮图像
目前,它正在提示按钮正常,并且工作得很好,除了当我滚动我的tableview,然后对按钮进行任何进一步的更改(检入或结帐),按钮图像将叠加旧的图像,而不是更新绘制。
我只是好奇,有没有解决这个问题?
我的代码看起来是这样的:
我对的cellForRowAtIndexPath代码如下所示:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomTableCell";
CustomTableCell *cell = (CustomTableCell *)
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"CustomTableCell"
owner:self options:nil];
cell = tableCell;
self.tableCell = nil;
}
CheckBox *chkBox = [[CheckBox alloc] init];
chkBox.frame = CGRectMake(10.0, -10.0, 50.0, 70.0);
[cell.contentView addSubview:chkBox];
[chkBox release];
cell.modelLabel.text =
[[[[[self regData] ShoppingCart] objectForKey:@"Cart"]
valueForKey:@"Model"] objectAtIndex:indexPath.row];
// Configure the cell...
return cell;
}
为方法是假设采取观众新的我还没有实现的didSelectRowAtIndexPath方法方法还屏幕提供更多信息。
请问您可以发布cellForrowatindexPath和heightForrowAtIndexPath的部分代码吗?从您给出的描述看来,您的自定义单元格有多个重叠的视图,或者存在重用单元格内容的问题。 – chatur
我用代码查尔更新了我的问题。 – kforkarim