Note that there are some explanatory texts on larger screens.

plurals
  1. POAuto layout invalid after presenting view controller (and many situation)
    primarykey
    data
    text
    <h3>Background:</h3> <p>I have a custom container controller, which just like UITabBarController, but with switch animation. And I use auto layout to achieve.<br> Because switch between child controllers is dynamic, the proper constraints are added to child view controller when its's view is added into container's view, not pre-setup in IB. (The constraints are added to the superview of course)</p> <p><a href="http://d.pr/i/q6NF" rel="nofollow noreferrer">http://d.pr/i/q6NF</a> Container Controller Nib Setup</p> <p>PS: The detail of constraints<br> H:|[Child](Change the constraint's constant to animation from left/right to right/left)<br> H:[Child(==Super)]<br> V:|[Child]| </p> <h3>Where is the Problem:</h3> <p>One of the child controller is a navigation controller, things go wrong when the navigation controller present a modal view controller (using <code>presentViewController:animated:completion:</code>), and dismiss it(using<code>dismissViewControllerAnimated:completion:</code>), after present/ dismiss the frame of navigation controller become (x, y, 0, 0), <strong>It seems like the auto layout becomes invalid, maybe the constraints been removed.</strong></p> <p><a href="http://d.pr/i/VmvL" rel="nofollow noreferrer">http://d.pr/i/VmvL</a> The Present/ Dismiss Process</p> <h3>Research</h3> <p>I haven't use code to verify what happen to these constraints yet, but with Spark Inspector I see the views presentation change during the present/ dismiss process. When My navigation controller present a modal view controller, iOS just <strong>swap</strong> the whole navigation controller's view to the modal view controller's view. And when navigation controller's view come back, the auto layout doesn't work anymore.</p> <h3>Possible Solution</h3> <p>One of the solution I came up with is let my container controller present modal controller.</p> <p>Or I just change my container controller to no auto layout.</p> <p>The fact is ever since I start using auto layout, the problems this technique causes just dominate the benefits. <strong>Besides this problem</strong>, Every time the interface orientation changes, views inside my container controller just can't auto layout right, it seems subviews always use the frame of superview before orientation change. I double check the constraints I setup, there is no conflicts and no ambiguity.</p> <p><strong>My guess</strong> is that my custom container controller isn't compatible with presenting modal view controller and interface orientation change in Auto Layout system, even with constraints setup.</p> <h3>Xcode Environment</h3> <p><strong>Xcode 5 beta, iOS 7SDK, target iOS6.1</strong> Maybe Something not right with the SDK environment?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload