Cordova:在UIWebView中禁用点击延迟(300毫秒点击延迟)

时间:2019-03-14 05:32:56

标签: objective-c cordova ionic-framework uiwebview phonegap

我一直在通过Internet寻找此问题的解决方案。但是我得到的唯一答案是使用Fastclick。尽管Fastclick适用于基本用途,但它会增加触摸事件的JavaScript执行开销,从而导致jank。我发现有关“被黑”的UIWebView的有趣post。作者建议添加一些“ hack”代码:

for (UIView* view in webView.scrollView.subviews) {
    if ([view.class.description equalsString:@"UIWebBrowserView"]) {
        for (UIGestureRecognizer *gestureRecognizer in view.gestureRecognizers) {
            if ([gestureRecognizer isKindOfClass:UITapGestureRecognizer.class]) {
                UITapGestureRecognizer *tapRecognizer = (UITapGestureRecognizer *) gestureRecognizer;
                if (tapRecognizer.numberOfTapsRequired == 2 && tapRecognizer.numberOfTouchesRequired == 1) {
                    tapRecognizer.enabled = NO;
                    break;
                }
            }
        }
        break;
    }
}

但是不幸的是,我没有使用Objective-C的经验。有谁知道如何将此“ hack”添加到新的Cordova iOS项目中?

0 个答案:

没有答案