iOS - Workaround for manually focusing on an input/textarea

前端 未结 5 1582
栀梦
栀梦 2020-12-05 13:07

So I\'ve seen a lot of threads about the iOS issue with focusing on an input/textarea element. (See here and here) It seems that iOS will not let you manually focus on one o

5条回答
  •  情书的邮戳
    2020-12-05 13:31

    WKWebView version of keyboardDisplayRequiresUserAction = NO from thedyrt/cordova-plugin-wkwebview-engine:

    #import 
    
    - (void) viewDidLoad {
        ...
    
        SEL sel = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
        Class WKContentView = NSClassFromString(@"WKContentView");
        Method method = class_getInstanceMethod(WKContentView, sel);
        IMP originalImp = method_getImplementation(method);
        IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {
            ((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3);
        });
        method_setImplementation(method, imp);
    }
    

提交回复
热议问题