iPhone table 实现动态加载图片的教程
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;?
}
详细解决方案
iPhone table 兑现动态加载图片的教程
热度:112 发布时间:2016-04-25 06:30:24.0
相关解决方案
- iphone 模拟器,该如何处理
- jsp页面中加了<table>元素后,页面出现了一大片空白后才出现表格?解决方法
- jsp页面中加了<table>元素后,页面出现了一大片空缺后才出现表格
- Unknown table 'book' in field list
- VS2010 RDLC 报表 表(table) 分页的时候怎么显示表头
- Table 布局怎么改用CSS定位
- sql清空表数据用truncate table 表名处理,若表名是以数字开头,或者完全是数字,这句会报语法异常
- sqltxet能不能这么写成"select *rowid from table"
- 大哥们救上命啊ArgumentException: 列“xxx”不属于表 Table
- 有哪位高手用过JPlayer ,进来一下,IPHONE 等设备播放有关问题
- 要取TextBox里的值插入表, insert into table value(); 括号里应该如何写
- 在类名上这样写是啥[Table(Name = "Product")]解决方法
- html中<table>和<asp:Tabel>有什么不一样啊该如何解决
- JS预览 Table
- 怎么自动补充html中<table>中的宽度和高度
- 关于<table class="Text">
- 如何能不让GridView变成<table>
- HTML用在<table>上的cellpadding、cellspacing在css里对应的是什么解决方案
- 元素"tr"不能嵌套在元素"table"中,该怎么处理
- ◆◇◆ 帮小弟我将 table 转成 div 。◆◇◆
- |M| 今天看了孟子E章的设置 table 中的cellSpacing="0" cellPadding="0" 可以但有点不理解,麻烦大家说明一下,该如何解决
- Column "xxx" does not belong to table Table,该怎么解决
- ALTER TABLE pet_type ADD CONSTRAINT pet_type_pk PRIMARY KEY (id),该怎么解决
- CREATE TABLE EMP(职员信息表)在SQL中如何排序
- ALTER TABLE pet_type ADD CONSTRAINT pet_type_pk PRIMARY KEY (id)解决方案
- 单个人去做手机开发选什么平台好?android,iphone?解决办法
- Sqlite database table is locked解决方法
- ASA6.0truncate table,该怎么处理
- sqlite沒有lock table?该如何解决
- Sqlite database table is locked解决办法