gpt4 book ai didi

ios - 无法识别的选择器发送到实例,与 View 无关

转载 作者:行者123 更新时间:2023-11-30 11:51:36 28 4
gpt4 key购买 nike

我的 iOS 应用程序遇到了一个恼人的问题。突然,当我启动带有 TableView 的 View Controller 时,出现以下错误:

Unrecognized selector sent to instance

在谷歌上搜索了很多关于这个问题的信息后,似乎它通常与错误连接的 IBOutlet/IBAction 或通常与 UI 相关的东西有关。

但是我可以排除这些原因,因为我删除了所有 IBOutlet 并且问题仍然存在。

经过很长时间,我找到了解决方案,并想以问答的方式分享它,以防其他人在这方面遇到困难。

最佳答案

问题出在这行代码:

outletCommentShowMore.attributedText = NSAttributedString(
string: isExpanded ? "show less" : "show more",
attributes: [
NSAttributedStringKey.foregroundColor : Theme.primaryTextColor,
NSAttributedStringKey.underlineStyle : NSUnderlineStyle.styleSingle
]
)

错误是我将枚举(NSUnderline.styleSingle)直接传递到 NSAttributedString 的属性字典中。但它必须是枚举的 rawValue!
因此,将其更改为 NSUnderline.styleSingle.rawValue 后,我的错误消失了

希望这对某人有帮助

关于ios - 无法识别的选择器发送到实例,与 View 无关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48281370/

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