CoreText の操作に苦労しています。私が何か間違ったことをしているのか、それとも iOS 自体のバグなのかわかりませんが、ここに私が持っているものがあります: iOS 5.0 では、このコードはビューの表示中にアプリをクラッシュさせます
- (void)viewDidLoad
{
[super viewDidLoad];
UIFont * font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
NSDictionary * attrs = @{(NSString *)kCTFontAttributeName:font};
NSAttributedString * attrStr = [[NSAttributedString alloc] initWithString:@"Test" attributes:attrs];
CATextLayer * textLayer = [[CATextLayer alloc] init];
textLayer.frame = self.view.frame;
textLayer.string = attrStr;
[self.view.layer addSublayer:textLayer];
}
EXC_BAD_ACCESS を作成しCoreText TAttributes::TAttributes(__CFDictionary const*):
、例外が発生したアセンブラの行を表示して開きます。
私は何か間違ったことをしていますか?私はほぼ8時間苦労していますが、何が起こっているのかまだわかりません.
アップデート
問題はどういうわけかこの行に基づいているようです
NSDictionary * attrs = @{(NSString *)kCTFontAttributeName:font};
Font 属性を削除して ForegroundColor 属性を追加すると、突然機能し始めるためです。深く掘り下げてみますが、まだ助けが必要です。