UIWebView在下拉时崩溃

问题描述:

我们在UIWebView中用选择控件(下拉)加载HTML,当我们点击下拉时,应用程序崩溃。这只在文本长文本的情况下才会发生,但在短文本中正常工作。UIWebView在下拉时崩溃

当我们调试时,我们发现它来自UIWebView的UIPopoverController中的UILabel问题。当UILabel有两行文本时,这个问题正在发生,单行很好。我们无法确定它是否与故事板或设置等相关的问题。

任何帮助将不胜感激。

这里是崩溃

* thread #1: tid = 0x1bd3, 0x034ad930 CoreFoundation`CFArrayGetValueAtIndex + 112, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) 
frame #0: 0x034ad930 CoreFoundation`CFArrayGetValueAtIndex + 112 
frame #1: 0x007d1b41 CoreText`TCharStream::CopyBreakIterator(__CFString const*) + 261 
frame #2: 0x007d18f4 CoreText`TCharStream::FindLineBreak(CFRange, bool, __CFString const*) const + 246 
frame #3: 0x00758a4a CoreText`TTypesetter::SuggestLineBreak(TLine const&, long, double, double) + 328 
frame #4: 0x007586b9 CoreText`CTLineSuggestLineBreakWithOffset + 55 
frame #5: 0x0839d89f UIFoundation`__NSStringDrawingEngine + 20275 
frame #6: 0x08398940 UIFoundation`-[NSString(NSExtendedStringDrawing) boundingRectWithSize:options:attributes:context:] + 201 
frame #7: 0x01b265c1 UIKit`-[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 1425 
frame #8: 0x01b25e7e UIKit`-[UILabel textRectForBounds:limitedToNumberOfLines:] + 85 
frame #9: 0x01d1d0cb UIKit`-[UITableViewCellLayoutManager intrinsicContentSizeForCell:] + 554 
frame #10: 0x01c16594 UIKit`-[UITableViewCell sizeThatFits:] + 46 
frame #11: 0x02092ade UIKit`-[UIView(UIConstraintBasedLayout) systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:] + 130 
frame #12: 0x01c01c9f UIKit`-[UITableViewCell systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:] + 220 
frame #13: 0x01a3f847 UIKit`-[UITableView _heightForCell:atIndexPath:] + 386 
frame #14: 0x01a302fb UIKit`__53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke + 2244 
frame #15: 0x019987af UIKit`+[UIView(Animation) performWithoutAnimation:] + 82 
frame #16: 0x019987f8 UIKit`+[UIView(Animation) _performWithoutAnimation:] + 40 
frame #17: 0x01a2fa2f UIKit`-[UITableView _configureCellForDisplay:forIndexPath:] + 355 
frame #18: 0x01a381da UIKit`-[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 503 
frame #19: 0x01a3829e UIKit`-[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 77 
frame #20: 0x01a11a6b UIKit`-[UITableView _updateVisibleCellsNow:isRecursive:] + 3034 
frame #21: 0x01a2c3d1 UIKit`-[UITableView layoutSubviews] + 222 
frame #22: 0x019a1dd1 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608 
frame #23: 0x02f55771 libobjc.A.dylib`-[NSObject performSelector:withObject:] + 70 
frame #24: 0x0061f28f QuartzCore`-[CALayer layoutSublayers] + 152 
frame #25: 0x00613115 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 397 
frame #26: 0x00612f70 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 26 
frame #27: 0x005713c6 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 284 
frame #28: 0x0057278c QuartzCore`CA::Transaction::commit() + 392 
frame #29: 0x00572e58 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92 
frame #30: 0x034fa9de CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 
frame #31: 0x034fa920 CoreFoundation`__CFRunLoopDoObservers + 400 
frame #32: 0x034f035a CoreFoundation`__CFRunLoopRun + 1226 
frame #33: 0x034efbcb CoreFoundation`CFRunLoopRunSpecific + 443 
frame #34: 0x034ef9fb CoreFoundation`CFRunLoopRunInMode + 123 
frame #35: 0x04d4224f GraphicsServices`GSEventRunModal + 192 
frame #36: 0x04d4208c GraphicsServices`GSEventRun + 104 
frame #37: 0x019168b6 UIKit`UIApplicationMain + 1526 

*帧#38:0x000f85bd main(argc=1, argv=0xbff5e584) + 141 at main.m:16 frame #39: 0x04400ac9 libdyld.dylib启动+ 1个

感谢, 维杰

+0

它没有给出任何例外。仅在main()函数中崩溃。我只能通过在崩溃期间在控制台中键入bt来获取堆栈跟踪 – 2014-12-13 16:31:48

这已解决。这个问题是因为硬编码“AppleLanguages”NSDefaults字符串的关键。当UIWebview尝试显示UILabel时,它会尝试将AppleLanguages作为Array读取并崩溃。

这是一个重复,在这里看到我的回答:https://*.com/a/26692948/4206060

总之,把这个放到你的网络查看代理中:

-(void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion 
{ 
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_USEC), dispatch_get_main_queue(), 
       ^{ 
        [super presentViewController:viewControllerToPresent animated:flag completion:completion]; 
       }); 
} 
+1

我已经检查过该文章,但是这个问题与UIWebView中的不同。我试过这个电话,但没有运气。 – 2014-12-14 05:12:34