UITableView在应用程序加载后加载图像
问题描述:
因此,我正在编写一个应用程序,并从网站网址获取专辑图稿。UITableView在应用程序加载后加载图像
基本上我迄今写的是如何读入一个文件,其中包含专辑封面的URL。然后,使用文件中的数据构建二维NSMutableArray,并从文件中的单个URL初始化UIImages,然后将其存储在数组中。
然后将该数组加载到UITableView中。
这很好用...除了它需要像加载应用程序(lol)10秒钟。
那么一旦加载UITableView,有什么方法来加载图像?
这是我的cellForRowAtIndexPath方法,如果有帮助。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"identifier"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"identifier"]autorelease];
}
((UILabel *)[cell viewWithTag:artistTag]).text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:artistIndex];
((UILabel *)[cell viewWithTag:albumTag]).text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:albumIndex];
((UILabel *)[cell viewWithTag:dateTag]).text = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:dateIndex];
((UIImageView *)[cell viewWithTag:imageTag]).image = [[musicList.list objectAtIndex:indexPath.row] objectAtIndex:imageIndex];
return cell;
}
非常感谢!
答
AFNetworking是异步加载非常好,甚至还带有功能用于处理图像加载(例如专辑封面)。 github回购包括示例代码。