01 | - (UITableViewCell *)tableView:(UITableView *)tableView |
02 | cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
04 | [NSThread detachNewThreadSelector:@selector(startImageread:) toTarget:self withObject:indexPath]; // 获取图片 |
08 | -(void)startImageread:(NSIndexPath *)indexPath |
09 | { UIImage *newimage = ......// 从本地或者网络获取图片 |
10 | NSDictionary *cellimage = [NSDictionary dictionaryWithObjectsAndKeys: |
11 | indexPath, @"indexPath", |
14 | [self performSelectorOnMainThread:@selector(_setOCellImage:) withObject:cellimage waitUntilDone:YES]; |
17 | - (void)_setOCellImage:( id )celldata |
19 | UIImage *newimage = [celldata objectForKey:@"image"];//从参数celldata里面拿出来图片 |
20 | NSIndexPath *indexPath = [celldata objectForKey:@"indexPath"]; |
21 | [self.DataTable cellForRowAtIndexPath:indexPath].imageView.image = newimage; |
转载于:https://my.oschina.net/LangZiAiFer/blog/126776