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