0

释放 CGPath 对象时,我遇到了崩溃,我完全被难住了。崩溃发生在类中方法末尾的CoreTextHyperlinkView库中。- (void)drawInContext:(CGContextRef)ctx bounds:(CGRect)boundsJSCoreTextView

基本上它使用核心图形/文本来绘制带下划线的文本。它创建一条路径,绘制它,然后释放它。

这是相关的堆栈跟踪:

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];
4

0 回答 0