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://lszwz.com/article/jogicp.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款