如何在創建單元格後獲取單元格的索引路徑?我需要設置一個uniq cell.tag。任何其他想法我怎麼能做到這一點?獲取UITablieViewCell的索引路徑
- (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;
}
的原因是我需要找到細胞在不同的thred
[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];
}
}
}];
does not this question your own question - [self.tableView indexPathForCell:cell]? –
我願意接受上面的評論作爲答案。 @Tom Fobear。 –
它會的。但它不起作用。它總是返回零。 – Chris