创建单元后如何获取单元的索引路径?我需要设置一个 uniq cell.tag。还有其他想法我该怎么做吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForManagedObject:(NSManagedObject *)managedObject
{
ConditionCell *cell = (ConditionCell *)[tableView dequeueReusableCellWithIdentifier:[ConditionCell reuseIdentifier]];
if ( nil == cell )
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ConditionCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else
{
// Reset Image
cell.img.image = nil;
}
原因是我需要在不同的线程中找到单元格
[condition processImageDataWithBlock:^(NSData *imageData) {
if (self.view.window) {
if (cell.tag == [self.tableView indexPathForCell:cell].row)
{
NSLog(@"%@",cell.tag);
UIImage *image = [UIImage imageWithData:imageData];
[condition writeToFile:imageData];
if (image)
{
cell.img.image = image;
[cell.activityIndicator stopAnimating];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[self.tableView indexPathForCell:cell]] withRowAnimation:UITableViewRowAnimationNone];
}
[condition release];
}
}
}];