gpt4 book ai didi

ios - 将长字符串设置为 UILabel 卡住我的应用程序并出现未检测到的错误

转载 作者:行者123 更新时间:2023-11-29 05:22:30 25 4
gpt4 key购买 nike

(我使用https://www.charactercountonline.com来计算我的字符串,那么我的字符串是2253个字符)我想用长字符串设置 UILabel,但我的应用程序一直卡住,并且在 xcode 中没有错误登录。

我尝试使用较短的字符串设置 UILabel,并且成功了!我在设置 UILabel 时尝试使用 DispatchQueue,但它也一直卡住且不显示错误日志。

DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
contentLabel.text = text }

我该如何修复它?这让我困了好几天。

编辑:我尝试对字符串的值进行硬编码。 this is exactly the line where problem occured这正是发生问题的行

最佳答案

尝试使用DispatchQueue.main.async,没有任何延迟,即

DispatchQueue.main.async {[weak self] in
self?.contentLabel.text = text
}

上面的代码对于任何长度的文本都可以完美工作。

关于ios - 将长字符串设置为 UILabel 卡住我的应用程序并出现未检测到的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58536789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com