Domanda

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!

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top