1
我想调整表视图的最后一行的高度。在尝试查找最后一行的索引时,我似乎遇到了某种递归循环。在我heightForRowAtIndexPath:
方法我有以下几点:UITableView委托方法
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGFloat height = 60;
NSInteger lastSectionIndex = [tableView numberOfSections] - 1;
NSInteger lastRowIndex = [tableView numberOfRowsInSection:lastSectionIndex] - 1; // BLOWS UP!
if ((indexPath.section == lastSectionIndex) && (indexPath.row == lastRowIndex)) {
height = 44;
}
return height;
}
如果我调整了代码只是一点点,它的工作原理。
NSInteger lastRowIndex = [self tableView:tableView numberOfRowsInSection:lastSectionIndex] - 1; // WORKS!
任何Objective-C/iOS大师都可以对这里发生的事情有所了解吗?为什么一种语法在另一种语法上工作?他们不是完全一样的方法吗?
你可以看看这里的代码方面:https://github.com/phungkytown/chapter8_gold
任何帮助,不胜感激!