I am working on a specific size class layout of an xcode project and I hit a snag.
My constraints got very messed up and I want to restart the view.
Is there a way in the interface builder for me to reset a size class (e.g wAny hCompact) back to its any constraints settings? (i.e. back to how it was with wAny hAny)
This should really be an automatic process in Interface Builder, but as far as I know it is not so you have to do the dirty work.
The best solution I have found is a combination of using Interface Builder and the source editor for this task. Remember that there are two things to reset, both the auto-layout constraints as you are referring to, but also the variations you might have created. Lets start with auto-layout constraints, and deal with variations later:
Reseting auto-layout constraints
Find a constraint you want to reset. Choose the "Show Size Selector" panel in the utilities view. At the bottom you will see the size classes this constrain has been added to. If it is only installed on the size class you want to reset, you can delete the whole constraint, otherwise, just delete it from the size class you want to reset by clicking the cross.
Variations
I have only managed to reset variations using the source editor. Either use an external editor, or "Open As -> Source Code", and search for variation
elements. Make sure the size class key is correct, and delete at will.
Found a quick fix for this.
In the Storyboard go to the file inspector tab, then, under "Interface Builder Document" Section, uncheck the "Use Size Classes" checkbox and it will ask you to keep either iPhone or iPad current layout.
After choosing it, you can check "Use Size Classes" again and the other size classes will reset to the one you chose before.
Note: All other size classes will reset to the chosen class!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With