LayoutSubviews called again on ios6 after CATransaction

I inherited a project that was too complicated (so I don’t know all the internal workings), and I am facing an error. In some parts of my application, there are several long animations done with CATransaction, and it looks like you are making multiple calls to layoutSubviews while the animation is active. This does not happen on ios5, and everything looks right, but on ios6 it is called non-stop and interferes with the large layout of the view. The stack trace is hidden / grayed out, but it seems to start with CA::Transaction::commit()

Has anything changed using CATransaction between ios versions to trigger something like this?

+6
source share
2 answers

See this post: UIView / CALayer: transform layoutSubviews triggers in view mode

Apple answered me through TSI:

Why do I see this behavior? is this inconsistency or do I not understand some basic concepts?

The view will be marked for layout whenever the system feels that something has changed, which requires the view to recalculate the scope of its subzones. This can happen more often than you expected, and it is when the system selects the presentation flag, since the required layout is an implementation detail.

why does it cascade up the hierarchy of representations?

Typically, changing the geometric property of a view (or layer) will cause the layout invalidation cascade up the view hierarchy, because parent views can have Auto Layout constraints with a modified child. Note that the automatic layout is active in some form, regardless of whether you explicitly enabled it.

how can i avoid the supervisor in layoutSubviews every time i change the transform?

This behavior cannot be circumvented. This is part of the UIKit internal accounting documentation, which is necessary to ensure consistency in the presentation hierarchy.

+1
source

Sounds like a startup problem. Does the view use any of its Autolayout subzones? Autolayout is good, but it doesn’t seem very fast and efficient, so animation problems can occur.

Of course, it may be necessary for the routines to be laid out every step in the animation if the shape of the size of one view changes so that it affects the placement or size of the object. Consider the animation and what effects it has.

0
source

All Articles