在CGPath对象上调用CGPathRelease时,在_CFArrayGetValueAtIndex上崩溃

时间:2013-08-28 20:49:15

标签: iphone ios core-graphics core-text

在发布CGPath对象时,我遇到了一个让我完全陷入困境的崩溃。 - (void)drawInContext:(CGContextRef)ctx bounds:(CGRect)boundsJSCoreTextView方法末尾的CoreTextHyperlinkView库中发生了崩溃。

基本上它使用Core Graphics / Text绘制带下划线的文本。它创建一个路径,绘制它,然后释放它。

以下是相关的堆栈跟踪:

Thread 0 Crashed:
0   CoreFoundation                      0x319058b6 _CFArrayGetValueAtIndex + 2
1   MyApp                               0x00300891 -[JSCoreTextView drawInContext:bounds:] (JSCoreTextView.m:678)
2   MyApp                               0x00300c5f -[JSCoreTextView drawRect:] (JSCoreTextView.m:709)
3   UIKit                               0x337ded61 -[UIView(CALayerDelegate) drawLayer:inContext:] + 365
4   QuartzCore                          0x3358f315 -[CALayer drawInContext:] + 113
5   QuartzCore                          0x3358e8c3 CABackingStoreUpdate_ + 1779
6   QuartzCore                          0x3358e037 CA::Layer::display_() + 975
7   QuartzCore                          0x335850b7 CA::Layer::display_if_needed(CA::Transaction*) + 203
8   QuartzCore                          0x33584fe1 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 25
9   QuartzCore                          0x335849c3 CA::Context::commit_transaction(CA::Transaction*) + 239
10  QuartzCore                          0x335847d5 CA::Transaction::commit() + 317
11  QuartzCore                          0x33584639 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 61
12  CoreFoundation                      0x3199b941 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 21
13  CoreFoundation                      0x31999c39 __CFRunLoopDoObservers + 277
14  CoreFoundation                      0x31999f93 __CFRunLoopRun + 747
15  CoreFoundation                      0x3190d23d _CFRunLoopRunSpecific + 357
16  CoreFoundation                      0x3190d0c9 _CFRunLoopRunInMode + 105
17  GraphicsServices                    0x354ec33b _GSEventRunModal + 75
18  UIKit                               0x338292b9 _UIApplicationMain + 1121
19  MyApp                               0x0003fad7 main (main.m:13) 

似乎CGPath内部的一些数组引起了问题。这可能只是iOS中的核心文本或核心图形错误吗?由于我无法查看iOS SDK的源代码,因此我不知道如何进一步调查。

我们只在修改后的BlockAlertView中使用此视图,如下例所示。我们从英语或阿拉伯语中获取JSON API中的文本,其中可能包含要强调和链接的电子邮件地址或URL。

JSCoreTextView *coreTextView = [[JSCoreTextView alloc] initWithFrame:CGRectMake(kAlertViewBorder, _height, frame.size.width-kAlertViewBorder*2, size.height)];
coreTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
coreTextView.delegate = self;
coreTextView.text = message;
coreTextView.textColor = _messageColor;
coreTextView.textAlignment = kCTCenterTextAlignment;
coreTextView.fontName = _messageFont.fontName;
coreTextView.fontSize = _messageFont.pointSize;
coreTextView.linkColor = _messageColor;
coreTextView.highlightedLinkColor = _messageLinkColor;
coreTextView.highlightColor = _messageColor;
coreTextView.backgroundColor = UIColor.clearColor;
coreTextView.underlined = YES;           
[_view addSubview:coreTextView];

0 个答案:

没有答案