iOS關于IQKeyboardManager 切換系統(tǒng)手寫崩潰問題

快過年了,最近要上線系統(tǒng),本來開開心心的 都沒什么問題了,結果上線前測試大哥用他專業(yè)變態(tài)的妓術手段,測出了這個之前被忽略的問題.

經過是這樣的:
UITextField 在切換iOS系統(tǒng)手寫輸入時會出現(xiàn)crash問題,測試機系統(tǒng)版本9.3.1


微信圖片_20180206161521.jpg

Xcode調試
崩潰斷點停在IQKeyboardManager文件中

顯示崩潰原因是

-[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 0x13fdca4a0

crash原因:
鍵盤上的手勢和View上的手勢沖突了

解決方法:
創(chuàng)建一個UIScrollView的category添加已下方法

- (void)touchesBegan:(NSSet *)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];
        }
    }
}

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容