How To Reset A Size Class Auto-Layout Back To Its wAny hAny Defaults?
Asked Answered
F

2

12

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)

Fleury answered 6/10, 2014 at 18:19 Comment(0)
C
5

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.

Corybantic answered 23/10, 2014 at 6:9 Comment(1)
Honestly I completely abandoned Interface Builder. It has too many problems to count. I now create all my views programatically (no storyboards no xibs) and from JSON files and I haven't looked back. 100x more efficient.Fleury
J
2

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!

Janinejanis answered 25/4, 2016 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.