iPhone学习之路 Table实现动态加载图片
iPhone学习之路 Table实现动态加载图片是本文要介绍的内容,内容不多,基于代码实现,我们一起来看内容。Iphone在加载列表时,如果每个等待把所有列表中的数据都加载完在显示相关内容,如果列表中有一些比较大的图片,加载的时间比较长,那么给用户的效果就很差了,下面详细是一种实现动态加载图片的办法:
[*]- (UITableViewCell *)tableView:(UITableView *)tableView
[*] cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[*] UITableViewCell* cell = ;
[*] if (cell==nil) {
[*] cell = [[ initWithStyle:UITableViewCellStyleSubtitle
[*] reuseIdentifier:@"tag"] autorelease];
[*] }
[*] //表格设计
[*] NSDictionary* one = ;
[*] cell.textLabel.text = ;
[*] cell.detailTextLabel.text = ;
[*] ;
[*] return cell;
[*]}
[*]
[*]- (void)updateImageForCellAtIndexPath:(NSIndexPath *)indexPath
[*]{
[*] NSAutoreleasePool *pool = [ init];
[*] UIImage *image = ;
[*] UITableViewCell *cell = ;
[*] ;
[*] ;
[*] ;
[*]}
[*]-(UIImage *)getImageForCellAtIndexPath:(NSIndexPath *)indexPath
[*]{
[*] id path = [ objectForKey:@"image"];
[*] NSURL *url = ;
[*] NSData *data = ;
[*] UIImage *image = [ initWithData:data cache:NO];
[*] return image;
[*]}
源代码:http://easymorse-iphone.googlecode.com/svn/trunk/WelcomePavilion/
小结:iPhone学习之路 Table实现动态加载图片的内容介绍完了,希望本文对你有所帮助!
本文来自:http://wangjun.easymorse.com/?p=908
【编辑推荐】
[*]iPhone开发入门教程 图解
[*]iPhone SDK 多线程使用方法以及注意事项
[*]iPhone开发 在模拟器中添加视频
[*]iPhone应用程序 实现截屏功能
[*]解析iPhone屏幕双缓冲技术
[*]iPhone学习 Sqlite数据库读写图片实例
页:
[1]