小编lik*_*eSo的帖子

我实现了EstimatedHeightForRowAt indexPath后,UITableView崩溃了吗?

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
    let cellHeight = self.promotionListViewList[indexPath.row].tableViewHeight.value
    if cellHeight < 0 {
        return 1.0
    } else {
        return cellHeight
    } 
}
Run Code Online (Sandbox Code Playgroud)

当我取消注释此方法并在iPhone5或iPad2上运行项目时,出现以下异常:

“表格视图行的高度不能为负-为索引路径提供的高度”

然后应用崩溃

但为什么?

我没有用这种方法产生负值。

如果我发表评论,那什么也没发生。

uitableview ios swift

3
推荐指数
1
解决办法
542
查看次数

标签 统计

ios ×1

swift ×1

uitableview ×1