ios - 在 UITableview 内的自动调整大小的标签上设置非常非常长的文本会破坏 NSLayoutConstraint

标签 ios swift uitableview autolayout

我在 UITableview 中有一个自动调整大小的单元格。我使用 AutoLayout 和 UITableViewAutomaticDimension 作为行高。

它适用于所有情况,甚至对于很长的文本(Lorem ipsum 的 2000 个单词)也是如此。

但是当我设置一个非常长的文本时,例如Lorem Ipsum 的 5000 个单词,我的文本在末尾被截断,日志如下

This NSLayoutConstraint is being configured with a constant that exceeds internal limits. A smaller value will be substituted, but this problem should be fixed. Break on BOOL _NSLayoutConstraintNumberExceedsLimit(void) to debug. This will be logged only once. This may break in the future.

这是我的限制。

enter image description here

以前有人遇到过这个问题吗?此问题的解决方法是什么。

最佳答案

您已经超过了 UILabel 能够容纳的最大尺寸(令人烦恼的是,Apple 的文档中没有对此进行定义)。如果您需要那么长的文本,您应该使用 UITextView。要使其行为与 UILabel 相同,请确保设置 isEditable = false

关于ios - 在 UITableview 内的自动调整大小的标签上设置非常非常长的文本会破坏 NSLayoutConstraint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52706274/

相关文章:

Swift:使用 Array<Character> 或 Slice<Character> 类型参数的 Join 方法在 Release 配置中崩溃

ios - 带有 UIWebView 和标签的 ScrollView

ios - 获取不同部分中选定单元格的列表

objective-c - 核心剧情: Two plots sharing the same x axis

iphone - Bonjour 数据发送多个设备

ios - 如何强制具有自定义扩展名的文本文件在 myApp 中打开而不是在 Safari 中显示为文本

ios - Pixate 将边框应用于单边

iOS 更改在 for 循环中创建的 UIButton 中的颜色

iphone - 自定义表格单元格背景图片

Swift Firebase 将数据检索到 TableView 中