UIWebView Bug: -[UIWebView cut:]: unrecognized selector sent to instance

后端 未结 4 1796
时光取名叫无心
时光取名叫无心 2021-02-04 03:43

In the UIWebView, if an input element containing text has focus, and a button is pressed that causes the input to lose focus, then subsequently double-tapping on th

4条回答
  •  心在旅途
    2021-02-04 04:19

    If you don't mind that there is no callout for cut/paste/etc. in the case, when the UIWebview is wrongly becoming first responder, then you can also fix it with this category. This does not prohibit cut/paste/etc. when the UIWebDocumentView (correctly) becomes first responder.

    @implementation UIWebView (NoWrongPerformWebview)
    
    - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
    {
        return NO;
    }
    
    @end
    

    // Swift 4 compliant version

    import UIKit
    
    extension UIWebView {
    
        override open func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
            // Should be respond to a certain Selector ??
            return responds(to: action)
        }
    }
    

提交回复
热议问题