我正在使用伟大的TTTAttributedLabel(https://github.com/mattt/TTTAttributedLabel)在iOS 5下工作正常.但是在iOS 6下,我收到错误:
-[__NSCFType set]: unrecognized selector sent to instance 0x200020e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFType set]: unrecognized selector sent to instance 0x200020e0'
Run Code Online (Sandbox Code Playgroud)
稍微研究了这个问题后,似乎将设置的消息发送到已经发布的对象.使用调试器,我已经po'd 0x200020e0,它似乎是CTFontRef.
po 0x200020e0
(int) $0 = 536879328 CTFont <name: .HelveticaNeueUI-Bold, size: 20.000000, matrix: 0x0>
CTFontDescriptor <attributes: <CFBasicHash 0x20001900 [0x3c2a4100]>{type = mutable dict, count = 1,
entries =>
1 : <CFString 0x3be2a768 [0x3c2a4100]>{contents = "NSFontNameAttribute"} = <CFString 0x3c292c14 [0x3c2a4100]>{contents = ".HelveticaNeueUI-Bold"}
Run Code Online (Sandbox Code Playgroud)
}
这让我直接找到了设置TTTAttributedLabel的代码:
[label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) …Run Code Online (Sandbox Code Playgroud)