加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 05:25:47 所属栏目:百科 来源:网络整理
导读:我试图用NSAttributed字符串为字符串加下划线.由于某种原因,我的行导致异常: -[_SwiftValue _getValue:forType:]: unrecognized selector sent to instance 结果应该用于UITableView中的UILabel,并根据需要创建. 这是代码: attributedString = NSMutableAt
我试图用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]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读