How do I reset specific size class data on a storyboard in Xcode6?
Asked Answered
K

2

8

I am using size classes to create a storyboard that can target all the various screen sizes and orientations. I have been working in the Any Width-Any Height size class. I ran into a display issue and decided to make those changes in the Compact Width - Regular Height size class. At a Later time, I was able to resolve my layout issue by making constraint changes to the Any Width-Any Height size class. How can I revert the changes made to the Compact Width - Regular Height size class so that the Any Width-Any Height size class will be used at runtime without manually reverting the changes?

Kermes answered 30/10, 2014 at 14:6 Comment(0)
L
6

I had a similar problem where I edited a few constraints for the iPad in the wrong size class (Any Width - Regular Height instead of Regular Width - Regular Height) and it ended up messing up the layout for portrait iPhone. I ended up editing Base.lproj/Main.storyboard and changed the appropriate <variation> entries to move the constraints to the proper size class (in my case, from <variation key="heightClass=regular" ..> to <variation key="heightClass=regular-widthClass=regular ...>. There must be a better way to do this, but this quick hack solved my problem in that occasion. To remove variations, deleting the corresponding variation entries should work (but make sure you have a backup in case something goes wrong).

Laburnum answered 17/12, 2014 at 15:55 Comment(1)
Thanks. I will check it out. Hopefully Apple implements a better way, but right now I just need a way to get it done.Kermes
F
2

XCODE7...

I had a similar problem with images added while in Regular Width (rather than "Any") not appearing when I switched it back to "wAny hAny" size.

I found in the Main.storyboard file, when viewed as code rather than visually, a section for the view in question as follows:

                        <variation key="default">
                        <mask key="subviews">
                            <exclude reference="bQ8-Fl-U5l"/>
                            <exclude reference="eyq-ch-Aan"/>
                            <exclude reference="pm5-gT-AYv"/>
                            <exclude reference="LJc-xi-hYb"/>
                            <exclude reference="y0y-l5-aTs"/>
                            <exclude reference="cLR-e1-OJo"/>
                        </mask>
                        <mask key="constraints">
                        </mask>
                    </variation>
                    <variation key="widthClass=regular">
                        <mask key="subviews">
                            <include reference="bQ8-Fl-U5l"/>
                            <include reference="eyq-ch-Aan"/>
                            <include reference="pm5-gT-AYv"/>
                            <include reference="LJc-xi-hYb"/>
                            <include reference="y0y-l5-aTs"/>
                            <include reference="cLR-e1-OJo"/>
                        </mask>

It appears that the section refers to the "Any-Any" case, and the refers to the specific Size Class I was playing with (being Regular Width, Any Height).

To fix it I DELETED the items EXCLUDED from the default section, and DELETED this same entries that had been added to the regular section. That section of the code then looks like...

                     <variation key="default">
                        <mask key="subviews">

                        </mask>
                        <mask key="constraints">
                        </mask>
                    </variation>
                    <variation key="widthClass=regular">
                        <mask key="subviews">

                        </mask>

Seems to fix it. Whacky, eh?

Flaminius answered 9/10, 2015 at 4:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.