-[UITraitCollection displayScale] should not default to 0.0

Originator:davbeck
Number:rdar://20627102 Date Originated:20-Apr-2015 05:50 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 8.3
Classification:Other Bug Reproducible:Always
 
Summary:
If a view or view controller is not part of a window view hierarchy, traitCollection has a blank empty instance (but not nil). In this state, displayScale is set to 0.0. This causes major issues if you try to get the physical pixel size of the device for a hairline size (1.0 / self.traitCollection.displayScale). With any other default, the normal workflow of the code should update when the traitCollection changes. But with 0.0, because of math, you get NaN, which causes a crash when used with Core Animation.

Steps to Reproduce:
Try to create a default size for a view based on the displayScale before it is added to a window hierarchy.

Expected Results:
The value should default to either 1.0 or the main screens displayScale.

Actual Results:
0.0, which causes NaN which causes crashes.

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!