我从服务器获取数据,其中包含一些我从 url 正确获取的图像,并将其正确设置为 tablview 单元格。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AppDelegate * delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text=[delegate.firstArray objectAtIndex:indexPath.row];
NSLog(@"%@",delegate.thirdArray);
url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[delegate.thirdArray objectAtIndex:indexPath.row]]];
data = [[NSData alloc]initWithContentsOfURL:url];
UIImage * img=[UIImage imageWithData:data];
cell.imageView.image=img;
return cell;
}
在 delegate.thirdArray 中包含这个 url
"http://awe.com/app/images/can.png",
"http://awe.com/app/images/card.png",
"http://awe.com/app/images/tp.png",
"http://awe.com/app/images/tricks.png"
图像加载正确,但加载该图像并滚动表格视图需要一些时间它会非常慢我希望它快我该怎么做。