是否有方法從選定的NSIndexPath中獲取行的高度?我不想通過委託方法設置行高度,但是如果我有一個不同行高的表格,並且想要獲得用戶觸摸的行的高度(或在我的情況下捏),我該如何做那?這是我認爲會起作用的,但事實並非如此。從選定的NSIndexPath中獲取rowHeight
- (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;
}
}
當我打印indexPath.accessibilityFrame.size.height時,我得到null。我試圖通過NSLog()獲取行到該行,但我碰到了一個崩潰EXC_BAD_ACCESS,我不知道爲什麼。當我打印indexPath的描述時,我得到的是內存,然後是[0,9]。有什麼想法嗎?謝謝。