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
任何幫助,不勝感激!