[英]single cell height in UITableView Xcode 5
Sorry i know this question has been asked before but i can't seem to get it to work, i would like to change the height of the first cell in my UITableView and keep the rest as default 44. I have implemented the below code (tried various others) and my application builds but the cell height does not change. 抱歉,我知道之前曾有人问过这个问题,但我似乎无法使其正常工作,我想更改UITableView中第一个单元格的高度,并将其余单元格保持默认值44。我实现了以下代码(尝试了其他方法),我的应用程序得以构建,但像元高度没有变化。 Any help on this would be great. 任何帮助都会很棒。
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) {
return 150;
}
else {
return 44;
}
}
estimatedHeightForRowAtIndexPath
is used to calculate the position / size of the scroll bar on the side when using autoLayout, not the cell height. 用于在使用autoLayout时计算侧面滚动条的位置/大小,而不是单元格高度。 You need: 你需要:
heightForRowAtIndexPath
How did this code work out for you? 该代码如何为您工作?
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0)
return 150;
else
return 44;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.