0

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?

Mihai Popa
  • 892
  • 1
  • 8
  • 25

1 Answers1

1

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.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151
  • The first solution works but it is somehow a hack. For example, if I have multiple buttons, I have to bring them all to front.IMHO, the second solution is not good practice, because for VCs transitioning, the views should not be manipulated directly. What I am trying to do is to find a more standard way to keep the view of the newly added VC in the same Z position of the old VC. – Mihai Popa Aug 23 '13 at 09:42