我想达到以下效果调用heightForRowAtIndexPath:如何从功能
- 用户水龙头,如果收缩,或者扩大合约一度对细胞
- 细胞膨胀。
到目前为止,我有一个单一的水龙头侦听工作职能:
- (void)handleSingleTap:(UITapGestureRecognizer *)gestureRecognizer {
CGPoint p = [gestureRecognizer locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p];
if(indexPath != nil) {
[self.tableView beginUpdates];
*Call heightForRowAtIndexPath here?*
[self.tableView endUpdates];
}
}
而且我heightForRowAtIndexPath
:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"runs");
return 64;
}
据我已经能够提供帮助弄清楚从不同的网站在线,我不得不在[self.tableView beginUpdates]
和[self.tableView endUpdates]
之间调用函数。 但我该怎么做?我并不熟悉Xcode或Objective C,所以一个好的解释将不胜感激!
在此先感谢。
Aleksander。
感谢您的快速反应马提亚! (我不知道这是否是一个问题,但是):当我启动应用程序时,“runs”被打印到控制台4次。我希望这个功能只在一次点击时被调用。此外,还有其他地方我也会使用'beginUpdates'和'endUpdates',例如删除和重新排列单元格。 这会是一个问题吗?这是一个好的解决方案吗?有更好的解决方案吗? 再一次,谢谢:) – Aleksander
'tableView:heightForRowAtIndexPath:'调用tableView中的每个单元格,这就是tableViews的工作方式。这不是问题,而是预期的行为。删除日志。 –