的iOS 7.1崩溃,如果heightForRowAtIndexPath没有声明 [英] iOS 7.1 crash if heightForRowAtIndexPath is not declared

查看:403
本文介绍了的iOS 7.1崩溃,如果heightForRowAtIndexPath没有声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用 estimatedHeightForRowAtIndexPath 与自动版式动态单元格高度和预期iOS8上,但说这iOS7.1美眉工作:

I was trying to use estimatedHeightForRowAtIndexPath for dynamic cell height with AutoLayout and working as expected in iOS8 but crush in iOS7.1 by saying this:

***终止应用程序由于未捕获的异常'NSInvalidArgumentException',原因:' - [MyProject.ViewController的tableView:heightForRowAtIndexPath:]:无法识别的选择发送到实例0x79e91350

如果我定义 heightForRowAtIndexPath ,错误消失,但细胞不会自动调整大小本身。任何想法?

If I define heightForRowAtIndexPath, error go away but cell won't auto size itself. Any idea?

更新:它在iOS的7.0确实可用,右

Update: It's indeed available in iOS 7.0, right?

推荐答案

尝试:

 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}
    }

这篇关于的iOS 7.1崩溃,如果heightForRowAtIndexPath没有声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆