Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 9 setting label with 0 lines to height of 14,600.5 in stack view

Tags:

xcode

ios

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.

Before

After

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).

like image 764
shaunjacobsen Avatar asked Sep 20 '17 20:09

shaunjacobsen


2 Answers

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.

like image 200
itopaloglu83 Avatar answered Oct 23 '22 01:10

itopaloglu83


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.

like image 5
Dennis Lau Avatar answered Oct 23 '22 01:10

Dennis Lau