【发布时间】:2014-11-06 14:53:26
【问题描述】:
我发现 UILabel 的一些奇怪行为带有属性文本和表情符号图标。不知道如何解决。
这是我每次在文本字段上更改文本时都在执行的代码。
NSLog(@"bef %@", self.textView.attributedText);
self.textView.attributedText = [[NSMutableAttributedString alloc] initWithString:self.textView.text];
NSLog(@"after %@", self.textView.attributedText);
输出是:
bef qwe{
NSFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSOriginalFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
}????{
NSFont = "<UICTFont: 0x7fc88a4d6aa0> font-family: \"Apple Color Emoji\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSOriginalFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
}1{
NSFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
}
2014-11-06 15:49:04.256 Inbot Dev[31162:506070] after qwe{
NSFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSOriginalFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
}????1{
NSFont = "<UICTFont: 0x7fc88a4d6aa0> font-family: \"Apple Color Emoji\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSOriginalFont = "<UICTFont: 0x7fc88b0e23d0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
}
实际问题是 Emoji 后的“1”进入 Emoji 块,但它不应该。 我正在对 NSMutableAttributedString 进行一些自定义装饰,这只是我缩小范围的一个问题示例。
更有趣的是,只有数字才会发生,如果我在 Emoji 之后加上字母就可以了...
似乎在设置属性文本时,它正在为 Emoji 做一些额外的事情。以前有人遇到过这个问题吗?
【问题讨论】:
标签: ios objective-c uilabel nsattributedstring emoji