Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 833
Aggressor Avatar asked Oct 06 '14 18:10

Aggressor


2 Answers

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.

like image 79
hcf Avatar answered Oct 18 '22 18:10

hcf


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!

like image 22
Steve Scerri Avatar answered Oct 18 '22 19:10

Steve Scerri