In Xcode 9 I am following along to the AppCoda tutorial to get started in iOS development. I noticed some odd behavior and am wondering if this is a bug or something I am not understanding with stack views in the Interface Builder (since the app does compile and displays correctly on my phone).
When I place the Label and set it as the third element in the stack view, a sibling of two other nested stack views, it appears fine if the default attributes are used. However, when I change the lines property from 1 to 0, the label and the adjacent stack view disappear from the interface builder.
In the size inspector, the coordinates for the label changed from 0,208.5 to 0,-90. If I change these properties, the height of the label changes from 0,0 to 375,14600.5, and Xcode throws an error: Interface Builder does not support UILabel sizes larger than 10,000 by 10,000.
Is this a bug with Xcode, or is there some changed behavior with the lines attribute for this version of Xcode (the book currently covers Xcode 8).
Here's a solution. Select the label view and go to the size inspector. Under label preferences check the explicit size box. This prevents the stack view from collapsing when you put a multiple line label into it.
Set Size Inspector > Intrinsic Size > Placeholder, set width to none and height to say 30
From description: Setting a design time intrinsic content size only affects a view while editing in Interface Builder. The view will not have this intrinsic content size at runtime.
From Xcode Help: Use a placeholder intrinsic size to indicate a view’s width and height and avoid design time constraint ambiguity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With