iPhone UITableView异步加载图片
来源:互联网 发布:品茗网络计划 注册码 编辑:程序博客网 时间:2024/05/17 13:09
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier] autorelease];
}
[NSThread detachNewThreadSelector:@selector(updateImageForCellAtIndexPath:) toTarget:selfwithObject:indexPath];
UIFont *font = [UIFont fontWithName:@"Helvetica" size:17];
//cell.textLabel.text = [dataArray objectAtIndex:indexPath.row];
cell.textLabel.text = @"ok";
cell.textLabel.font = font;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)updateImageForCellAtIndexPath:(NSIndexPath *)indexPath{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIImage *image = [self getImageForCellAtIndexPath:indexPath];
if (image) {
NSLog(@"image ok %d",indexPath.row);
}
UITableViewCell *cell = [self.tbView cellForRowAtIndexPath:indexPath];
CGRect rect;
UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(KNewCollectionImageViewX+5, kTopButtonMargin,KShopCellImageViewWidth, KShopCellImageViewHeight)];
iv.tag = KImageViewTag;
iv.backgroundColor = [UIColor clearColor];
rect = iv.frame;
//iv.image = image;
[cell addSubview:iv];
//cell.imageView.image = image;
//[cell.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
[iv performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];
[iv release];
//[image release];
[pool release];
}
-(UIImage *)getImageForCellAtIndexPath:(NSIndexPath *)indexPath{
// id path = [[dataArray objectAtIndex:indexPath.row] objectForKey:@"image"];
//id path = [imageArray objectAtIndex:indexPath.row];
//id path = @"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSString *path = @"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
//UIImage *image = [[UIImage alloc] initWithData:data cache:NO];
// NSURL *url = [NSURL URLWithString:path];
//NSData *data = [NSData dataWithContentsOfURL:url];
//UIImage *image = [[UIImage alloc] initWithData:data cache:NO];
//UIImage *image = [[UIImage alloc] initWithData:data cache:NO];
UIImage *image = [UIImage imageWithData:data];
if (image) {
NSLog(@"%@",path);
}
return image;
}
- iPhone UITableView异步加载图片
- iPhone UITableView异步加载图片
- iPhone UITableView异步加载图片 (动态加载图片)
- UITableView 异步加载图片
- UITableView异步加载图片
- UITableView异步加载图片
- UITableView异步加载图片
- UITableView 异步加载图片
- iPhone 异步加载图片
- iphone 异步加载图片
- ipad iphone 异步图片加载
- UITableView异步加载图片+缓存
- UITableView 实现异步加载图片之改进
- iOS UITableView中异步加载图片
- ios UITableView封装之下拉-上提-图片异步加载
- ios UITableView封装之下拉-上提-图片异步加载
- ios UITableView封装之下拉-上提-图片异步加载 .
- ios UITableView封装之下拉-上提-图片异步加载
- repeater控件
- 查看某个用户的表建在哪个表空上
- 【爱生活】关元穴能有效调理身体
- 使用ADO.NET的DbProviderFactory读取或写入Excel中的表单
- vim-水木-global命令
- iPhone UITableView异步加载图片
- spring-ibm-deplover
- Linux编程经典书籍推荐
- vim-水木-插入模式下命令
- AIX小机基本情况查询
- android NDK的第一个实验
- 搞嵌入式的,想去培训要想好
- PL/SQL ORA-12154: TNS: 无法解析指定的连接标识符
- 浏览器开发工具的25个秘密