【发布时间】:2013-09-04 10:37:04
【问题描述】:
我正在从服务器获取数据,其中包含一些我从 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"
图像加载正常,但加载该图像并滚动表格视图需要一些时间,它会非常慢我希望它快我该怎么做。
【问题讨论】:
-
此问题与您的信誉级别不匹配...无论如何尝试延迟加载...
-
h kishan 你能帮我解决这个问题吗..
-
我建议你先完整获取所有图像,然后将它们添加到 tableView..
-
查看我的回答您的问题将得到解决
-
我认为这个问题每天至少被问一次
标签: iphone ios objective-c xcode uitableview