【发布时间】:2012-06-24 20:15:33
【问题描述】:
我有一个自定义的 UITabvleViewCell,其中有一个 UIImageView。当在 cellForRowAtIndexPath 中设置单元格时,我可以很好地设置图像(尽管我没有)但是在某些条件下我需要更改图像并且一直在使用以下代码进行更改。
-(void)updateCellForUPC
{
AppData* theData = [self theAppData];
NSInteger cellIndex;
for (cellIndex = 0; cellIndex < [productArray count]; cellIndex++) {
NSString *cellUPC = [NSString stringWithFormat:@"%@",[[productArray objectAtIndex:cellIndex] objectForKey:@"UPC"]];
if ([cellUPC isEqualToString:theData.UPC]) {
OrderDetailCell *activeCell = [[OrderDetailCell alloc] init];
activeCell = (OrderDetailCell *) [orderDetailTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:cellIndex inSection:0]];
UIImage* image = [UIImage imageNamed:@"checkmark.png"];
activeCell.statusImageView.image = image;
activeCell.checked = YES;
}
}
}
这很有效,并且图像会更新,但是当您将单元格从屏幕上滚动并返回到屏幕上时,图像会被重置!
我需要它来*坚持新图像。
【问题讨论】:
标签: ios uitableview