好吧,我很确定这个方法一直在为我的 UITableViewController
执行到现在。我的方法中有这样的打印语句:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//455(PERFECT MIN HEIGHT) 475 is perfect spacing. 15.5 is the scalar for when descriptionLabel expands lines
return 475;
NSLog(@"ISSSS ITTT ONNNN???");
if (currentDescriptionHeight == 16.0) {
NSLog(@"OHHH so it triggered 1111");
return 475;
}else if (currentDescriptionHeight == 31.5){
NSLog(@"OHHH so it triggered 2222");
return 490.5;
}else if (currentDescriptionHeight == 47){
NSLog(@"OHHH so it triggered 3333");
return 506;
}
//475 - 1 line description,
}
我已将方法 header 复制到我的 .h 文件中,并已正确设置委托(delegate):
self.tableView.delegate = self;
self.tableView.dataSource = self;
在我的 viewDidLoad:
方法中。为什么我的 heightForRowAtIndexPath
根本没有被调用?
最佳答案
您只需要将函数顶部的 return 语句移动到底部或将其作为当前 if 语句的一部分放在 else 中,因为 return 语句会立即结束函数,因此它下面的代码将永远不会执行。
关于ios - heightForRowAtIndexPath 从未被称为 iOS9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33226917/