Search code examples
iphoneiostransitionflipsubviews

Subviews not displaying during Flip Transition


I am doing a flip transition between two subviews of a container view. The container view is NOT fullscreen and is not the root view of the view controller (it is a subview thereof, taking roughly the bottom third of the screen).

Of the two child views being switched in the flip transition (both of them UIImageView), one of them has two children in turn (again, of UIImageView type). This subview is the one that "goes away" as a result of the transition.

As soon as the transition starts, the exiting UIImageView instance flips allright, but its two children disappear immediately. During the second half, the entering UIImageView instance appears with no problems (it has no children).

I have tried making the containing view fullscreen and opaque, to no effect. I read about contentMode, contentStretch and autoresizing masks but doesn't seem to be it.

I am using an old-style animation block. I tried setting the hidden property of the entering/exiting subviews inside the block, and adding/removing them inside the block, but the result is the same. I even tried using modern-syntax, Objective-C code blocks but still no change.


Solution

  • I found the answer: the children were being added just before the animation block begins (inside the same method as the animation block, few lines before ).

    I tested adding other children earlier on (say, at -viewDidLoad) and those stay during the animation.

    My guess is, changing the view hierarchy encompasses some asynchronous precessing beyond the one-line "addSubview:", and the new children didn't make it in time to be part of the animation. The animation block itself is asynchronous but a certain amount of things must certainly be fixed by the time you commit it (e.g., the view hierarchy structure).