组TableView,使用自我调整大小部分标题,重新加载后,如果我向上滚动,tableview将跳转 [英] Group TableView,using self sizing section header,after reload,if I scroll upward ,tableview will jump

查看:158
本文介绍了组TableView,使用自我调整大小部分标题,重新加载后,如果我向上滚动,tableview将跳转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个像这样的桌面视图:推特和评论;
在此输入图片说明

I am doing a tableview like this: a twitter and comments on it; enter image description here

我尝试了几种架构。我没有找到足够的问题和讨论。我认为这是一个非常有意义的问题,所以我发布了这些架构的性能和限制。

I have tried several architecture.I do not find enough question and discussion about this. I think it is a very meaningful question,so I post these architectures' performance and limitations.

首先,将整个单元格用作带有注释的twitter,注释视图将根据使用自行调整自动布局高度。

这个架构可以工作。但是如果一个Twitter有很多评论(30或更多),在旧的iPhone(4s,5,5s和所以,fps将下降到40.滚动平滑的明显阻止。这个性能瓶颈是这种架构的唯一弱点。

First,using whole cell as twitter with comments,which comments view will generate according to the model.Cell use self-sizing auto-layout height.
This architecture can work.But if a twitter have many comments(30,or more),in old iPhone(4s,5,5s and so on),fps will down to 40.Obvious block for scroll smooth.This performance bottleneck is the only weakness for this architecture.

其次,由于性能瓶颈,我想想也许我可以在twitter单元格中放置评论tableview。而twitter单元格和嵌入式评论单元格也使用自行调整自动布局高度。但是在尝试之后,我发现twitter单元格无法确认其高度,因为嵌入式评论表格视图无法确认其高度本身。所以我需要计算嵌入式注释tableview的高度以确认twitter单元的高度。这种架构也很有效。但它的性能瓶颈与第一架构相同。

Second,because of performance bottleneck,I think maybe I could put a comment tableview in a twitter cell.And twitter cell and embedded comment cell use self-sizing auto-layout height,too.But after try,I found that twitter cell can not confirm its height because the embedded comment tableview can not confirm its height itself.So I need to calculate the embedded comment tableview's height to confirm the twitter cell's height. This architecture works well,too.But its performance bottleneck is the same as first architecture.

第三,也是最重要的,使用节头作为推特,单元格作为评论。也就是说,一个部分是一个带注释的整个twitter。部分标题和单元格都使用自我调整自动布局高度。

这个体系结构的性能最好,甚至包含多达50多个评论的twitter,tableview即使在iPhone5中滚动也非常流畅,fps至少为55.但是有一些我无法解决的奇怪问题。

我滚动到底部,tableview将重新加载下一页。重新加载数据后,首先出现的问题是那段节目解除,但滚动后出现(后来我发现,如果我设置tableview标题,出现这个问题,如果我删除tableview标题,这个问题就消失了,所以很困惑)。第二个也是更重要的问题是如果我向上滚动, tableview将跳.Below是gif演示。(我不知道如何将大gif发布到StackOverflow,对不起)
https://github.com/yutanchi/GroupTableViewSectionHeaderJump/blob/master/tableviewjump.gif

我认为原因是tableview使用估计的部分标题高度而不是实际部分标题高度。我搜索了很多信息,但没有什么可以帮助我。我很困惑,如果节标题的自我调整机制与单元格的自我调整机制相同。为什么自定义单元格可以执行正确的行为,自定义节标题执行不。
因为这个体系结构具有明显的性能优势,我想确定自我调整大小部分标题有什么问题,解决这些恼人的问题并使用体系结构。有人可以解释或讨论这个吗?

Third,also the most improtant,using section header as twitter,cell as comment.That is,a section is a whole twitter with comments.Section header and cell both use self-sizing auto-layout height.
This architecture's performance is best,even twitter with as many as 50+ comments,tableview scrolls very smooth even in iPhone5,fps is at least 55.But there is strange problems that I can not solve.
I scroll to the bottom,tableview will reload next page.After reloadData,first little problem is that section header dismiss,but appear after scroll(Later I found that if I set tableview header,this problem appear,if I remove tableview header,this problem disappear,so confused).Second and more important problem is that if I scroll upward,tableview will "jump".Below is the gif demonstration.(I do not know how to post big gif to StackOverflow,I am sorry) https://github.com/yutanchi/GroupTableViewSectionHeaderJump/blob/master/tableviewjump.gif
I think the reason is that tableview use the estimated section header height but not the actural section header height. I have searched much information but nothing can help me.I am so confused that If section header's self-sizing mechanism is the same as cell's self-sizing mechanism.Why self-sizing cell can perform the right behavior,self-sizing section header do not. Because this architecture have obvious performance advantage,I want to make certain what's wrong with self-sizing section header,solve these annoying problems and use the architecture.Can someone explain or discuss this?

推荐答案

为此,您必须将所有约束放在所有元素的右上角。
另外
1-in viewDidLoad设置如下

For this you have to give all constrains left right top bottom to all elements. Also 1-in viewDidLoad set following

self.yourtableView.estimatedRowHeight= your estimated_height_for_Cell
yourtableView.rowHeight = UITableViewAutomaticDimension

将2行设置为零对于属性检查器中的标签。

2-set number of rows to zero For Labels in attribute inspector.

这篇关于组TableView,使用自我调整大小部分标题,重新加载后,如果我向上滚动,tableview将跳转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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