我需要为该字符串中的不同范围创建一个具有不同CTFontRef和CTParagraphStyleRef的CTParagraphStyleRef。
我尝试通过将以下代码放入循环并根据需要更改范围来创建它,
CTFontRef normalFontRef = CTFontCreateWithName((CFStringRef)@"CourierNewPSMT", fontsize, NULL);
NSDictionary* normalFontAttribute = [[NSDictionary alloc] initWithObjectsAndKeys:(id)normalFontRef,(NSString*)kCTFontAttributeName, nil];
[attributedString addAttributes:normalFontAttribute range:range];
CFRelease(normalFontRef);
[normalFontAttribute release];
normalFontAttribute = nil;
CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(theSettings, theNumberOfSettings);
NSDictionary* paragraphAttribute = [[NSDictionary alloc] initWithObjectsAndKeys:(id)paragraphStyle,(NSString*)kCTParagraphStyleAttributeName, nil];
[attributedString addAttributes:paragraphAttribute range:range];
CFRelease(paragraphStyle);
paragraphAttribute release];
paragraphAttribute = nil;我的问题是:
该应用程序崩溃后,在设备的一些循环迭代,没有显示任何细节。只要关闭应用程序,没有崩溃报告,没有消息在控制台,没有gdb断点。
更多解释:--我在另一个循环中调用这个NSMutableAttributedString创建方法,用于其他一些处理,该循环是崩溃的循环,而不是NSMutableAttributedString创建循环。但是,如果我注释了调用上述方法并使用create a NSMutableAttributedString,它可以正常工作,请参见下面的
//works fine
attributtedString = [[NSMutableAttributedString alloc] initWithString:stringContent];
//not working
attributtedString = [self createattributtedString:stringContent];
//this createattributtedString: method contain the first listed code 提前谢谢,
发布于 2011-06-27 13:58:17
你可能有个没完没了的循环。
https://stackoverflow.com/questions/6345780
复制相似问题