Is there a way of getting the height for a row from the NSIndexPath selected? I don’t want to set the row height through the delegate methods, but if I had a table of different row heights, and wanted to get the height of the row the user touched (or in my case pinched), how do I do that? This is what I thought would work, but it does not.
- (CGFloat)heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath && indexPath.section != NSNotFound && indexPath.row != NSNotFound) {
//NSUInteger rowTouched = [indexPath row];
//NSLog(@"%@", rowTouched);
//NSLog(@"%@", [indexPath description]);
return indexPath.accessibilityFrame.size.height;
}
else {
return 0;
}
}
When I print the indexPath.accessibilityFrame.size.height, I get null. I tried to get the row by NSLog() to the row, but I get a crash EXC_BAD_ACCESS which I’m not sure why. When I print the description of the indexPath, I get the memory where this is at and then [0,9]. Any thoughts? Thanks.
NSIndexPathdoesn’t haveaccessibilityFrameproperty as it is not aUIViewobject. THe index path and cell are not the same thing even though they are related. You should probably get thecellusingcellForRowAtIndexPath:method of theUITableViewand then pass its frame height.