2011-02-09 159 views
0

喜的朋友我正在显示图像的表格单元格说表有10个细胞UIITabelViewCell显示不正确的图像

,但我只在两种细胞

显示图像时,我滚动表视图此图像由一个上再来一个所有细胞

所以我在这里做错了什么。

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

您有错误的(最有可能的)cellForRowAtIndexPath:方法。有没有机会看到你的代码指向错误? – Vladimir 2011-02-09 12:04:16

+0

编辑你的问题并把你的代码放在它里面......在这段代码中,你将图像设置到单元格中了吗? – Vladimir 2011-02-09 12:10:23

回答

0

检查下面的方法并仅如果使用电池离队匹配indexpath.row整数值

 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    //check the indexPath 
    if(indexPath.row==0 || indexPath.row==5){ 
    } 
    else{ 
    //other stuff 
    } 

} 
0

添加图像,你取出的细胞可能是那些在它的图像之一。

因此,如果您的手机出列,您必须检查图像是否存在并将其删除。