设置NSUnderlineStyle会导致无法识别的选择器异常 [英] Setting NSUnderlineStyle causes unrecogognized selector exception
本文介绍了设置NSUnderlineStyle会导致无法识别的选择器异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用NSAttributed字符串加下划线.出于某种原因,我的行导致了异常:
I am trying to underline a string with NSAttributed string. For some reason, my lines cause the exception:
-[_SwiftValue _getValue:forType:]: unrecognized selector sent to instance
该结果应该用于UITableView中的UILabel,并根据需要创建.
The result is supposed to be used for a UILabel within a UITableView and is created as needed.
这是代码:
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]
这篇关于设置NSUnderlineStyle会导致无法识别的选择器异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文