【发布时间】:2013-12-31 21:12:22
【问题描述】:
我已经查看(并尝试了代码 sn-ps)this question,但想知道 iOS7 中是否出现了什么问题?更有可能是我做错了什么。
我的代码如下:
import <CoreText/CoreText.h>
NSString *tempString1 = [currentMemory valueForKey:@"title"];
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:tempString1];
[attString addAttribute:(NSString*)kCTUnderlineStyleAttributeName
value:[NSNumber numberWithInt:kCTUnderlineStyleSingle]
range:(NSRange){0,[attString length]}];
self.titleLabel.attributedText = attString;
self.titleLabel.textColor = [UIColor whiteColor];
我得到这个编译错误:
*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“NSConcreteMutableAttributedString initWithString:: nil value”
如果我使用纯文本
self.titleLabel.text = [NSString stringWithFormat:@"%@", tempString1];
它工作正常。任何帮助表示赞赏。
【问题讨论】:
标签: ios ios7 nsmutablestring