[英]Change cell subview height after cell animation is ended Swift
I use Swift 3.0
and have tableViewCell
and its subview. 我使用
Swift 3.0
并拥有tableViewCell
及其子视图。 I use heightForRowAt
function to change cellView
height. 我使用
heightForRowAt
函数来改变cellView
高度。
I have two states of cellView
: default and expanded. 我有两种状态的
cellView
:默认和扩展。 CellViewSubview
has visible borders. CellViewSubview
具有可见边框。
CellView
and cellViewSubview
are connected with leading
, trailing
, top
and bottom
constraints. CellView
和cellViewSubview
与leading
, trailing
, top
和bottom
约束相关联。 When I change the height of the cellView
, cellViewSubview
automatically changes its height to fit. 当我更改
cellView
的高度时, cellViewSubview
自动更改其高度以适应。 Also I need to say that cellView
is changing with animation, I use the following to implement this: 另外我需要说
cellView
正在改变动画,我使用以下来实现这个:
tableView.beginUpdates()
tableView.endUpdates()
Everything works fine except that the cellViewSubview
height is changed instantly without animation. 一切正常,只是
cellViewSubview
高度在没有动画的情况下立即改变。 So it means that I see how cellViewSubview
border 'jumps' to the top without animation. 所以这意味着我看到
cellViewSubview
边框如何在没有动画的情况下“跳跃”到顶部。
I faced with this problem only in IOS 10.0
. 我只在
IOS 10.0
遇到过这个问题。 In IOS < 10.0
animation was simultaneous. 在
IOS < 10.0
动画是同步的。 How to make the cellView
and the cellViewSubview
change their height simultaneously with animation? 如何让
cellView
和cellViewSubview
同时改变动画的高度?
Solution that worked for me: 对我有用的解决方案:
I've stopped using bottom equal constraint
between cellView
and cellViewSubview
. 我已经停止在
cellView
和cellViewSubview
之间使用bottom equal constraint
。 Instead of it I've set height constraint
to the cellViewSubview
and change its height after heightForRowAt
is complete. 而不是它我已经将
height constraint
设置为cellViewSubview
并在heightForRowAt
完成后更改其高度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.