简体   繁体   English

在细胞动画结束后更改细胞子视图高度Swift

[英]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. CellViewcellViewSubviewleadingtrailingtopbottom约束相关联。 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? 如何让cellViewcellViewSubview同时改变动画的高度?

Solution that worked for me: 对我有用的解决方案:

I've stopped using bottom equal constraint between cellView and cellViewSubview . 我已经停止在cellViewcellViewSubview之间使用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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM