简体   繁体   中英

UINavigationController pop resets frame of root viewcontroller

Interface Builder is set up to use autolayout, but no constraints are set for my root view controller. I have a button that moves views around in the root view controller. When I push a new viewcontroller onto the stack and subsequently pop it, the frames of the views on the root view controller are reset to their beginning locations.

Any theories on why that may be happening?

When you use Auto Layout, the frames of your views are determined by the constraints you set. If you don't modify your constraints and instead manually change your views' frames, then the next time your views are laid out their frames will once again be determined by the constraints set on them (and one time this happens is right before your view controller's view appears on screen, which is what you're seeing).

If you want these frame changes to hold after layout happens, you should modify your constraints (either by changing their constant values or by replacing them with entirely new ones) instead of the views' frames.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM