0
我已经在使用苹果的延迟加载例如UITableView的实现图片的延迟加载图像。除了一部分外,一切正常。最初,当我启动应用程序时,表格的可见单元格不会加载任何图像。但是当我滚动表格时,图像正在为其余单元格加载并被保留。但最初的可见单元格保持空白。延迟加载 - 可见的UITableView细胞中不显示
任何人都有类似的问题?
任何人都可以请指导我解决这个问题?
static NSString *EditCellIdentifier = @"EditCell";
UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:EditCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:EditCellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
for (UIView *view in cell.contentView.subviews){
[view removeFromSuperview];
}
if ([listItems count]>0)
{
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
ListItem * item = [listItems objectAtIndex:indexPath.row];
UIImageView *imageFrame = [[UIImageView alloc] initWithFrame:CGRectMake(5,5,60,60)];
[imageFrame setImage:[UIImage imageNamed:@"box.png"]];
UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 50, 50)];
otherPath=indexPath;
if (!item.appIcon)
{
if (self.tableView.dragging == NO && self.tableView.decelerating == NO)
{
NSLog(@"Initial Values %@",item.imageURL);
if([item.imageURL length]==0){
imageView.image=[UIImage imageNamed:[categoriesImages objectAtIndex:self.configfId - 1]];
}
else
[self startIconDownload:item forIndexPath:indexPath];
}
}
else
{
imageView.image = item.appIcon;
}
[imageView setBackgroundColor:[UIColor blackColor]];
NSString * titleStr = [NSString stringWithFormat:@"%@. %@",item.rank,item.title];
NSLog(@"titleStr %@",titleStr);
CGSize size = [titleStr sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:11] constrainedToSize:CGSizeMake(12, 100) lineBreakMode:UILineBreakModeWordWrap];
if (size.height > 50) {
size = CGSizeMake(size.width,50.0);
}
NSInteger height = 14;
if(item.title.length > 30){
height = 25;
}
[cell.contentView addSubview:imageView];
[cell.contentView addSubview:imageFrame];
}
return cell;
}
请将您的tableView的'代码:的cellForRowAtIndexPath:'你的问题。 – Codo 2012-07-30 12:35:59
什么是您的图像的来源,是这些本地或来自网络? – TheTiger 2012-07-30 12:39:10
几乎可以肯定你只加载图像,当你得到一个重绘,但作为第一个评论说,没有看到你的cellForRowAtIndexPath这纯粹是一种猜测 – Woody 2012-07-30 12:40:34