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 APP运行时Crash自动修复系统 前言 大白(Baymax),迪士尼动画《超能陆战队》中...
    鼠犬玉阅读 17,625评论 22 158
  • 1、禁止手机睡眠[UIApplication sharedApplication].idleTimerDisabl...
    DingGa阅读 4,813评论 1 6
  • 1、禁止手机睡眠 [UIApplicationsharedApplication].idleTimerDisabl...
    小热狗阅读 4,440评论 0 2
  • 我听朋友说:“为什么我老是伤害我最亲的人,不是行为上的,而是言语上的。”我颇有感触。某日,很晚了,不见老公回来,打...
    茜茜妈妈阅读 799评论 0 1
  • 打车到华南城,路上出租车司机是真的好能侃,天南海北的聊,在询问到深圳房价的时候,他还给我讲了一个故事,他是92年来...
    OO碰到OO阅读 2,744评论 0 0