资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

IOS延时加载TableView中Cell中的图片

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // do something
    [NSThread detachNewThreadSelector:@selector(startImageread:) toTarget:self withObject:indexPath]; // 获取图片
    // do something
}
-(void)startImageread:(NSIndexPath *)indexPath
{                                                                                                      UIImage *newp_w_picpath = ......// 从本地或者网络获取图片
    NSDictionary *cellp_w_picpath = [NSDictionary dictionaryWithObjectsAndKeys:
                               indexPath, @"indexPath",
                               newp_w_picpath,@"p_w_picpath",
                               nil];
    [self performSelectorOnMainThread:@selector(_setOCellImage:) withObject:cellp_w_picpath waitUntilDone:YES];
}
- (void)_setOCellImage:( id )celldata
{
    UIImage *newp_w_picpath = [celldata objectForKey:@"p_w_picpath"];//从参数celldata里面拿出来图片
    NSIndexPath *indexPath = [celldata objectForKey:@"indexPath"];
    [self.DataTable cellForRowAtIndexPath:indexPath].p_w_picpathView.p_w_picpath = newp_w_picpath;
}

分享名称:IOS延时加载TableView中Cell中的图片
分享链接:http://cdkjz.cn/article/jogicp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220