可能是重复问题:
带图片的表视图,加载和滚动缓慢
我有一个UITableView
,它从服务器下载UITableViewCells
的图片。我发现这个tableView滚动得非常慢。
我以为这可能是下载问题,但我已经意识到,在下载完成后,即使图标大小较小,表格仍然滚动缓慢。
我在谷歌上搜索了一下,但没有找到任何帮助。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
btnBack.hidden = FALSE;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.backgroundColor = [UIColor clearColor];
cell.textLabel.font = [UIFont fontWithName:@"Noteworthy" size:17.0];
cell.textLabel.font = [UIFont boldSystemFontOfSize:17.0];
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.highlightedTextColor = [UIColor blackColor];
}
cell.textLabel.text = [NSString stringWithFormat:@" %@", [test.arrTitle objectAtIndex:indexPath.row]];
NSString *Path;
Path = [NSString stringWithFormat:@"http://%@",[test.arrImages objectAtIndex:indexPath.row]];
NSLog(@"image-->%@",[test.arrImages objectAtIndex:indexPath.row]);
NSString *strImage = Path;
NSURL *url4Image = [NSURL URLWithString:strImage];
NSData *data = [NSData dataWithContentsOfURL:url4Image];
image =[[UIImage alloc] initWithData:data];
cell.imageView.image =image;
[image release];
return cell;
}