【发布时间】:2015-10-20 02:18:10
【问题描述】:
好吧,我很确定这个方法一直在为我的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,
}
我已将方法标头复制到我的 .h 文件中,并已正确设置委托:
self.tableView.delegate = self;
self.tableView.dataSource = self;
在我的viewDidLoad: 方法中。为什么我的heightForRowAtIndexPath 根本没有被调用?
【问题讨论】:
-
为什么函数开头有return语句?
-
呃,方法错误是因为只在条件句中没有返回?
-
return 语句立即结束函数,因此它下面的代码永远不会执行
-
你是对的..好吧我改变它,如果我需要一个开放式的非条件返回语句,我如何让它不返回 475?
-
可以,但是和把return语句移到函数末尾是一样的,你自己选择
标签: ios uitableview heightforrowatindexpath