2014-12-13 67 views
1

我們在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

回答

1

這已解決。這個問題是因爲硬編碼「AppleLanguages」NSDefaults字符串的關鍵。當UIWebview嘗試顯示UILabel時,它會嘗試將AppleLanguages作爲Array讀取並崩潰。

1

這是一個重複,在這裏看到我的回答:https://stackoverflow.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