美文网首页
iOS自带手写键盘奔溃问题

iOS自带手写键盘奔溃问题

作者: 想你的傻笑 | 来源:发表于2017-04-24 14:06 被阅读0次

很多时候为了满足需求,我们需要在UIScrollView添加UITextField,在处理键盘升降键盘事件的时候往往会写个UIScrollView的分类,代码

- (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];
}

后来我们的测试发现一个问题,当使用iOS自带手写键盘的时候输入第一个字变灰,再点击点击奔溃了。

调试了很久,我发现手写键盘在调用UIScrollView的这个分类的方法时,self的类型是UIKBCandidateCollectionView,具体是什么还没有去苹果官方文档查,先屏蔽了,代码

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    if (![self isMemberOfClass:[UIScrollView class]]) {
        
    } else {
        [[self nextResponder] touchesBegan:touches withEvent:event];
        if ([super respondsToSelector:@selector(touchesBegan:withEvent:)]) {
            [super touchesBegan:touches withEvent:event];
        }
    }
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    if (![self isMemberOfClass:[UIScrollView class]]) {
        
    } else {
        [[self nextResponder] touchesMoved:touches withEvent:event];
        if ([super respondsToSelector:@selector(touchesBegan:withEvent:)]) {
            [super touchesMoved:touches withEvent:event];
        }
    }
    
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if (![self isMemberOfClass:[UIScrollView class]]) {
        
    } else {
        [[self nextResponder] touchesEnded:touches withEvent:event];
        if ([super respondsToSelector:@selector(touchesBegan:withEvent:)]) {
            [super touchesEnded:touches withEvent:event];
        }
    }
}

解决

相关文章

  • iOS自带手写键盘奔溃问题

    很多时候为了满足需求,我们需要在UIScrollView添加UITextField,在处理键盘升降键盘事件的时候往...

  • iOS 手写输入法奔溃

    iOS 手写输入法奔溃,一种方法是常见的新建一个view监听点击手势,隐藏键盘,然后这个view最后加入到self...

  • iOS13 textfield的placeholder字体颜色崩

    由于iOS13禁止了textfield通过KVC获取私有属性,出现奔溃问题 奔溃报错Access to UITex...

  • iOS奔溃日志分析

    iOS奔溃日志分析 前言(扯淡) iOS奔溃日志能够比较有效的分析奔溃的原因,方便我们debug我们的项目。当然现...

  • DYLD, Library not loaded: /usr/l

    奔溃日志 奔溃表现:iOS12.1 及以下启动奔溃奔溃日志: 解决方法:关闭bitcode,重新打包上传appst...

  • iOS 9.x assets 导致的奔溃问题

    问题描述:上周新上传的版本在Bug收集中发现有几个地方出现很多次奔溃问题,问题都集中在iOS 9.x中奔溃机型分布...

  • iOS奔溃问题处理经验

    面对形形色色的奔溃问题,作为一个老码农,从最初的不知所措,慢慢也学会了和其共存共生。毕竟奔溃抓不完,但如何更好地抓...

  • iOS 9.3以下 Assets奔溃问题

    今天遇到一个 Assets奔溃问题的问题,记录一下 百度原因: 如果你的图片资源文件里有16位图或者图片显示模式为...

  • Xcode奔溃问题

    经常崩溃,一天开发下来崩溃数十次,无解试过删除xcuserdata,重装Xcode,都不起作用 电脑型号,以及系统...

  • UITextField奔溃问题

    项目在测试中遇到一个问题,当手机开启搜狗输入法点击textfield时软件会闪退,奔溃定位到了UIColor上。分...

网友评论

      本文标题:iOS自带手写键盘奔溃问题

      本文链接:https://www.haomeiwen.com/subject/mmtpzttx.html