문제

I have a custom view with a grid-like layout. When I touch each subview I want to animate them. The superview overrides layoutSubviews to create the grid of subviews.

The problem is whenever I change the frame of a subview for animation, the superview's layoutSubviews method is called overwriting the frame and no animation happens.

Why does layoutSubviews get called in this scenario and how can I prevent it?

There are other questions similar to this, but none of them have been properly answered.

Thanks!

도움이 되었습니까?

해결책

I ended up adding a flag property on my superview and then set it to YES from my subview to prevent it from laying out subviews. Seems very hacky but it works.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top