ios – UITableView自我调整单元格滚动问题,细胞高度差异很大

ios – UITableView自我调整单元格滚动问题,细胞高度差异很大,第1张

概述func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let json = JSON(data: activityTableView.onlineFeedsData)[indexPath.row] // new if(json
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卡片类型布局,有很多动态数据,文本和图像可变.可以有人帮助我.谢谢

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

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

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1104321.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存