[英]Swift dynamic width on UILabel is broken
Yesterday Apple released Xcode 12 GM and iOS 14 so I don't know if this is a bug or not.昨天苹果发布了 Xcode 12 GM 和 iOS 14,所以我不知道这是否是一个错误。
I've built an UIView with 3 UILabels in it.我已经构建了一个带有 3 个 UILabels 的 UIView。 These labels are filled and updated after an API request.
这些标签在 API 请求后填充和更新。 After I run my project in Xcode the UILabels are perfect, but after a second start the width of these labels are broken.
在 Xcode 中运行我的项目后,UILabels 是完美的,但在第二次启动后,这些标签的宽度被破坏了。
Really weird because this is not happened on the first run.真的很奇怪,因为这不是第一次运行时发生的。 These labels are filled with API data, so we can't set a fixed width.
这些标签填充了 API 数据,因此我们无法设置固定宽度。
Label settings:标签设置:
Text: Plain
Default text: -
Lines: 1
Line Break: Character Wrap
Baseline: Align Baselines
Screenshot after first start (Xcode build/run) on my iPhone with iOS 14:在使用 iOS 14 的 iPhone 上首次启动(Xcode 构建/运行)后的屏幕截图:
Screenshot after second start.第二次启动后的截图。 (force closed first session and clicked on app icon):
(强制关闭第一个会话并单击应用程序图标):
Xcode 12 contraints: Xcode 12 限制:
解决我的问题是:
label.sizeToFit()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.