Incorrect Fractional Value Returned With systemLayoutSizeFittingSize In View with UIStackViews
|Product:||iOS + SDK
||Product Version:||iOS 10.2|
systemLayoutSizeFittingSize is returning an incorrect fractional value sometimes with a particular view hierarchy setup using UIStackViews. The issue appears timing related because calling systemLayoutSizeFittingSize on subviews in the view hierarchy will prevent the fractional value from being returned.
Steps to Reproduce:
1. Download the sample project attached here or from this link:
2. Launch the app in a 2x resolution simulator such as iPhone 5s
3. Notice that the systemLayoutSizeFittingSize(UILayoutFittingCompressedSize) call on line 20 of ViewController.swift returns (1366.5, 96.0)
The systemLayoutSizeFittingSize(UILayoutFittingCompressedSize) call on line 20 of ViewController.swift should return (1366, 96.0) which appropriately respects the constraints applied to the view.
The systemLayoutSizeFittingSize(UILayoutFittingCompressedSize) call on line 20 of ViewController.swift returns (1366.5, 96.0) an incorrect fractional value.
I've simplified the sample project as much as possible to highlight the issue. The view setup is essentially a view with a UIStackView pinned to the edges that has a vertical axis, and center alignment with two subviews. The view then has a particular width constraint on it, 1366 width. This is the critical configuration that is producing the bug. If you change the alignment of the UIStackView to left alignment for instance, the bug will no longer present itself.
Also, if you uncomment the line of code on line 46 of TestView.swift the bug will not be reproduced.
Let me know if you have any questions.
iPhone & iPad simulators for @2x resolution devices
'UIStackView-Fractional-Bug.zip' was successfully uploaded.
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!