如果未声明heightForRowAtIndexPath,则iOS 7.1会崩溃

use*_*867 3 uitableview autolayout ios7 ios7.1

我试图estimatedHeightForRowAtIndexPath通过AutoLayout 使用动态单元格高度,并在iOS8中按预期工作,但在iOS7.1中通过这样说:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyProject.ViewController tableView:heightForRowAtIndexPath:]: unrecognized selector sent to instance 0x79e91350'

在此输入图像描述

如果我定义heightForRowAtIndexPath,错误消失,但单元格不会自动调整大小.任何的想法?

更新:它确实可以在iOS 7.0中使用,对吗?

在此输入图像描述

Bob*_*j-C 6

尝试:

 if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 ){
    self.tableView.rowHeight =  UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 206;
}




 func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {



        if NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 {              
return UITableViewAutomaticDimension
            } else {return 206}
    }
Run Code Online (Sandbox Code Playgroud)