Xcode 6.1.1: IB Designables report wrong trait collections when running inside IB

Originator:igeek1
Number:rdar://19702960 Date Originated:03-Feb-2015 02:24 PM
Status:Duplicate of 17278773 Resolved:10-Feb-2015 01:38 PM
Product:Developer Tools Product Version:Xcode 6.1.1 (6A2008a)
Classification:Serious Bug Reproducible:Always
 
Summary:
Interface Builder’s IBDesignable renderer passes incorrect values to -traitCollectionDidChange: when rendering designable classes.

Steps to Reproduce:
1. Open the attached sample code.
2. Open Main.storyboard.
3. Observe that the label in the middle of the xib is an instance of WordyTraitLabel, which sets its text property to its trait collection’s description in -traitCollectionDidChange:.
4. Use the size class control at the bottom of the canvas to cycle through all 9 permutations of horizontal and vertical size classes.

Expected Results:
The label’s reported trait collection matches the trait collection you specify at the bottom of the screen. Even if it does something fishy for the “Any” size classes, at least the “Regular”s and “Compact”s are reported accurately.

Actual Results:
Only 2 of the 9 possible configurations are reported correctly by the label: compact width/compact height, and regular width/compact height are reported correctly. Every other configuration is reported as either compact width/compact height or regular width/compact height. See attached image for a table of the results as reported by IB.

The trait collections are all reported perfectly at run time; the bug is IB-only.

Regression:
None - this has never worked as far as I know.

Notes:
This makes it hard to work with designable classes that change their appearance as a function of the trait collection. For example, I have UILabel subclass in a project that changes its font size depending on the trait collections. This bug makes it difficult to use IB as a WYSIWYG editor for these labels, since their apparent font sizes are not accurate until run time.

Attachments:
Table and sample code: http://cl.ly/ZcEz

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!