简体   繁体   中英

iOS Autolayout - constraints modifications lost on orientation change?

If I modify my constraints (lets say activate some and deactivate others) and then rotate to a different orientation my interface snaps back to the original unmodified state. How do I preserve this changes?

Are your constraints 'properties of the class'? Or they are local variables of a function which get deallocated after you change your orientation?

The general suggestion is to keep a reference/pointer to your constraints and instead of adding/removing constraints you activate/deactivate the constraints. See this moment of wwdc: Mysteries of Auto Layout, Part 1

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