iphone table 实现动态加载图片
来源:互联网 发布:python判断字符串查找 编辑:程序博客网 时间:2024/05/17 03:04
Iphone在加载列表时,如果每个等待把所有列表中的数据都加载完在显示相关内容,如果列表中有一些比较大的图片,加载的时间比较长,那么给用户的效果就很差了,下面详细是一种实现动态加载图片的办法:
- - (UITableViewCell *)tableView:(UITableView *)tableView
- cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"tag"];
- if (cell==nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
- reuseIdentifier:@"tag"] autorelease];
- }
- //表格设计
- NSDictionary* one = [array objectAtIndex:indexPath.row];
- cell.textLabel.text = [one objectForKey:@"title"];
- cell.detailTextLabel.text = [one objectForKey:@"content"];
- [NSThread detachNewThreadSelector:@selector(updateImageForCellAtIndexPath:) toTarget:self withObject:indexPath];
- return cell;
- }
- - (void)updateImageForCellAtIndexPath:(NSIndexPath *)indexPath
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- UIImage *image = [self getImageForCellAtIndexPath:indexPath];
- UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
- [cell.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
- [image release];
- [pool release];
- }
- -(UIImage *)getImageForCellAtIndexPath:(NSIndexPath *)indexPath
- {
- id path = [[array objectAtIndex:indexPath.row] objectForKey:@"image"];
- NSURL *url = [NSURL URLWithString:path];
- NSData *data = [NSData dataWithContentsOfURL:url];
- UIImage *image = [[UIImage alloc] initWithData:data cache:NO];
- return image;
- }
0 0
- iphone table 实现动态加载图片
- iphone table 实现动态加载图片
- iPhone table 实现动态加载图片的教程
- iPhone table 实现动态加载图片的教程
- iPhone table 实现动态加载图片的教程
- iPhone table 实现动态加载图片的教程
- iPhone table 实现动态加载图片的教程-TableView中图片的延时加载
- iphone动态加载图片
- iphone(UITableViewCell)动态加载图片
- iphone(UITableViewCell)动态加载图片
- iphone(UITableViewCell)动态加载图片
- iPhone学习之路 TableView实现动态加载图片
- iPhone UITableView异步加载图片 (动态加载图片)
- Flex 实现动态加载图片
- Promise实现图片动态加载
- Iphone 图片设置阴影和动态加载图片
- iPhone 异步加载图片
- iphone 异步加载图片
- GE Smallworld开发(006坐标系统设置)
- 关于freemarker 数字自动加逗号和判断非空
- 兼容xp、win7、win8、win8.1、32位、64位的shellcode
- 长虹引发的家电企业智能热
- 菜鸟谈测试生涯
- iphone table 实现动态加载图片
- SQL中判断字符串中包含字符的方法
- 短信平台
- 扶贫办官员:带贫困县帽子每年可获5000万资金
- 用PS将gif动态图片导出为多张单帧图片
- [屌丝PM]我经历的NUI变革期
- Fabric demo
- js 瀑布流
- ubuntu编译安装php5 mysql nginx