嗨朋友我在桌子上显示图像表示表格有10个单元格
但我只在两个单元格上显示图像
当我滚动表视图时,这个图像逐个显示在所有单元格上
所以我在这里做错了什么。
static NSString * identifier = @“CellTypeLabel”;
// create custom cell
CustomizedTableCells* cell = nil;
if (cell == nil)
cell = [[[CustomizedTableCells alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
// cell accessory type
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.imageView.image = nil;
NyhtrAppDelegate *appDelegate = (NyhtrAppDelegate *)[[UIApplication sharedApplication] delegate];
NSXMLElement* node = [appDelegate.items objectAtIndex:indexPath.row];
NSLog(@"\n Output :: %@ :: ", [node XMLString]);
// set the lable name for a cell
if(node != NULL)
{
int width = cell.contentView.bounds.size.width-50;
if([[[node elementForName:@"pubDate"] stringValue]length] > 0)
[cell setCellWithTitleAndSize:[[node elementForName:@"title"] stringValue] rect:CGRectMake(45, 0, width, 35) size: 17];
else
[cell setCellWithTitleAndSize:@"N/A" rect:CGRectMake(45, 0, width, 35) size: 17];
}
NSXMLElement* iconElement = [self getIconElementForThisDomain:[self getDomain:node]];
NSString* iconImageUrl = nil;
if (nil != iconElement)
iconImageUrl = [[iconElement elementForName:@"retina-icon"]stringValue];
else
iconImageUrl = @"http://nyhtr.se/icon/nyheter24.png";
// cached images
NSString* imageName = [[UICachedImageMgr defaultMgr] imageNameFromURLString:iconImageUrl];
UIImageProxy* imageProxy = [UICachedImageMgr imageWithName:imageName userInfo:self];
cell.imageView.image = imageProxy.image;
return cell;
答案 0 :(得分:0)
检查以下方法并仅将图像添加到匹配的indexpath.row整数值
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //check the indexPath if(indexPath.row==0 || indexPath.row==5){ } else{ //other stuff } }
答案 1 :(得分:0)
如果您使用单元格出列,则您出列的单元格可能是包含图像的单元格之一。
因此,如果您的单元格已经出列,则必须检查图像是否存在并将其删除。