ios - 为 iOS8 移除 "heightForRowAtIndexPath"

标签 ios ios7 ios8 deprecated heightforrowatindexpath

在找到解决方案之前,我试图解决这个问题两天。
这里是。

======

大家好,

我实际上使用委托(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/

相关文章:

ios - 如何使用 IBDesignable UIImageView 在 prepareForInterfaceBuilder 中加载图像

ios - UITableViewController 和 UICollectionViewController 的 .view 属性

ios - MapBox(iOS)上的动画标记注释

xcode - 使用 iOS8 的 iOS Over The Air 分发(iOS 7 工作正常)

sockets - 浏览器上的 GCDAsyncSocket 连接并立即断开连接,出现 "Socket closed by remote peer"错误

iOS 8 自定义键盘方向更改

ios - 请求错误代码为 999 的 AFNetworking

colors - UITextView 到 Mimic UITextField [用于基本圆角文本字段]

ios - 如何以编程方式在 UIScrollview 中创建 UIScrollview

ios - 第二次单击自定义选项卡栏时滚动到 View 顶部 : Objective-C