View controller containment Z position

231 Views Asked by At

I have the following issue: I create a view controller and I add a child view controller inside it. The child view controller view is inserted below an existing subview (button A) of the parent view controller. When I try to transition to a new child view controller, its view is not added anymore below button A, but above it.

Is there a way to keep the Z position of the child view?

1

There are 1 best solutions below

1
On

After adding the new view controller, call:

[parentView bringSubviewToFront:theButton];

Alternatively, use insertSubview:belowSubview: to insert the new view controller, specifying the button for the belowSubview: argument.