gpt4 book ai didi

swift - 设置 NSUnderlineStyle 导致无法识别的选择器异常

转载 作者:IT王子 更新时间:2023-10-29 05:15:14 34 4
gpt4 key购买 nike

我正在尝试使用 NSAttributed 字符串为字符串加下划线。出于某种原因,我的台词导致了异常:

-[_SwiftValue _getValue:forType:]: unrecognized selector sent to instance   

结果应该用于 UITableView 中的 UILabel,并根据需要创建。

这是代码:

attributedString = NSMutableAttributedString(string: message)

if let actor = event.actor {
let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle]
var attributedActorString = NSMutableAttributedString(string: actor.shirtName, attributes: attributes)
attributedActorString.insert(NSAttributedString(string: " "), at: 0)
attributedActorString.append(NSAttributedString(string: ". ")) attributedActorString.append(attributedImageStringForUrl(event.actor!.portraitImageUrl, indexPath: indexPath))
attributedString.append(attributedActorString)
}

最佳答案

换行:

let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle]

到:

let attributes = [NSUnderlineStyleAttributeName:NSUnderlineStyle.styleSingle.rawValue]

关于swift - 设置 NSUnderlineStyle 导致无法识别的选择器异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46092027/

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