iOS开发笔记-[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance

周一早上一开会,就听到一个噩耗,上线已久的app有一个必现的crash的bug,心情瞬间有些凉。

直接上问题吧

有一个用tableview做的一个填写表单页面,只要在填写时,切换到手写输入法,手写之后就会crash,然后错误提示:[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance,之前从来没遇到过这种错误,一直不知所措。只好求助万能的谷歌百度,原来是手势冲突原因。
由于之前开发的时候,为了让填写表单是弹出的键盘能点击空白处收回键盘,就给scrollview写了一个分类,重写了三个方法。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesBegan:touches withEvent:event];
[super touchesBegan:touches withEvent:event];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesMoved:touches withEvent:event];
[super touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[[self nextResponder] touchesEnded:touches withEvent:event];
[super touchesEnded:touches withEvent:event];
}

手写输入法和这个分类处理手势冲突导致app crash了。找到问题就好办了,最后放弃了这个分类,解决手写输入crash的bug,但是点击tableview空白收回键盘的功能也就失效了。最后只有往tableview上加一个tap手势,来收回键盘。键盘是回收了,但是tableview上一些cell不能点击跳转了,又是手势冲突。还好添加的手势有一个cancelsTouchesInView属性,文档解释:A Boolean value affecting whether touches are delivered to a view when a gesture is recognized.这个布尔属性默认是YES,就是会取消手势的传递到视图,所以在给tableview添加手势的时候,将次属性设置为NO,这样手势可以传递到tableview上,从而可以响应Cell的选择事件。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 见字如面。 一撇一捺,写给父母的信,一笔一画,书浓浓的爱意。字里行间是亲情,是依偎,是感恩。所谓爱,就要大声说出来...
    洋2017阅读 4,193评论 0 6
  • 今天的早餐,颜色稍微暗淡了一些,偏深沉。花卷也做得不算成功,唯一庆幸的就是甜瓜。那香甜,让人念念不忘,回味无...
    糖醋带鱼阅读 1,300评论 0 0