在找到解决方案之前,我试图解决这个问题两天。
这里是。
======
大家好,
我实际上使用委托(delegate)方法 heightForRowAtIndexPath 在 iOS7 中管理我的 tableViewCell 的高度:
现在,在 iOS8 中,我将属性 tableView.rowHeight = UITableViewAutomaticDimension 与自动布局一起使用,它比以前更好用。
问题是我需要从我的代码中删除 heightForRowAtIndexPath: 方法,否则该属性不起作用(高度设置在内部并控制该属性)。
如何仅在 iOS8 中删除此方法(可能使用编译指令,但我不知道是哪一个)?
我仍然需要它用于ios7。
via
最佳答案
试试这个
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(IS_IOS8){
return UITableViewAutomaticDimension;
}
else
{
int height; // your custom calculated height
return height;
}
}
关于ios - 为 iOS8 移除 "heightForRowAtIndexPath",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30916077/