iOS开发——UIWebView一些异常crash整理

采用 UIWebView 实现 hybrid 方案过程中,遇到过一些 crash,刚开始遇到的时候感觉特别诡异,这里整理一下,方便今后查阅。

unrecognized selector

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIWebView paste:]: unrecognized selector sent to instance 0x110f35fc0'

Last Exception Backtrace:
0   CoreFoundation                       ___exceptionPreprocess
1   libobjc.A.dylib                      _objc_exception_throw
2   CoreFoundation                       ___methodDescriptionForSelector
3   CoreFoundation                       ____forwarding___
4   CoreFoundation                       __CF_forwarding_prep_0
5   UIKit                                -[UICalloutBar buttonPressed:]
6   UIKit                                -[UICalloutBarButton fadeAndSendAction]
7   Foundation                           ___NSFireDelayedPerform
8   CoreFoundation                       ___CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
9   CoreFoundation                       ___CFRunLoopDoTimer
10  CoreFoundation                       ___CFRunLoopDoTimers
11  CoreFoundation                       ___CFRunLoopRun
12  CoreFoundation                       _CFRunLoopRunSpecific
13  GraphicsServices                     _GSEventRunModal
14  UIKit                                _UIApplicationMain
15  OneTravel                            main   main.m:14
16  libdyld.dylib                        _start

发现这个 crash 的时候,简直丈二和尚——摸不着头脑,整个项目压根就没有调用过这以为方法啊,抓狂了一会儿,立马想到了 Stack Overflow。于是找到了这个:

https://stackoverflow.com/questions/21316784/uiwebview-bug-uiwebview-cut-unrecognized-selector-sent-to-instance

原来如此,Apple 的坑,按照 ac 的 Answer 方案进行修复即可~今后再遇到如下 UIWebView 的 unrecognized selector,就知道如何处理了:

    "cut:", "copy:", "paste:","select:", "selectAll:", "delete:", "makeTextWritingDirectionLeftToRight:", "makeTextWritingDirectionRightToLeft:", "toggleBoldface:", "toggleItalics:", "toggleUnderline:", "increaseSize:", "decreaseSize:"

你可能感兴趣的:(iOS开发——UIWebView一些异常crash整理)