HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – UITableView自我调整单元格滚动问题,细胞高度差异很大大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
func tableView(tableView: UITableView,cellForRowATindexPath indexPath: NSIndexPath) -> UITableViewCell{

    let json = JSON(data: activityTableView.onlineFeedsData)[indexPath.row] // new
    if(json["topic"]["reply_count"].int > 0){
        if let cell: FeedQuestionAnswerTableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier_reply) as? FeedQuestionAnswerTableViewCell{

            cell.SELEctionStyle = .None
            cell.tag = indexPath.row
            cell.relatedTableView = self.activityTableView
            cell.configureFeedWithReplyCell(cell,indexPath: indexPath,rect: view.frame,key: "activityTableView")
            // Make sure the consTraints have been added to this cell,since it may have just been created from scratch
            cell.layer.shouldRasterize = true
            cell.layer.rasterizationScale = UIScreen.mainScreen().scale

            return cell
        }
    }else{
        if let cell: FeedQuestionTableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as? FeedQuestionTableViewCell{

            cell.SELEctionStyle = .None
            cell.tag = indexPath.row
            cell.relatedTableView = self.activityTableView
            cell.configureFeedCell(cell,rect: view.framE)
            // Make sure the consTraints have been added to this cell,since it may have just been created from scratch

            cell.layer.shouldRasterize = true
            cell.layer.rasterizationScale = UIScreen.mainScreen().scale
            return cell
        }
    }


    return UITableViewCell()
}

每个单元格的高度差异为200-400,因此尝试在estimatedHeightForRowATindexPath中实现高度计算.我不能将此方法中的精确估计高度作为计算的bcz

并在willDisplayCell方法中缓存高度,但滚动跳转仍然需要时间来渲染.

单元格就像Facebook卡片类型布局,有很多动态数据,文本和图像可变.可以有人帮助我.谢谢

解决方法@H_404_12@
如果您能够计算每个单元格高度,只需使用tableView(_:heightForRowATindexPath)而不是estimatedRowHeightATindexPath属性. estimatedRowHeightATindexPath主要用于smthg,如自缩细胞等.

大佬总结

以上是大佬教程为你收集整理的ios – UITableView自我调整单元格滚动问题,细胞高度差异很大全部内容,希望文章能够帮你解决ios – UITableView自我调整单元格滚动问题,细胞高度差异很大所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。