简体   繁体   中英

not able to select text in any input textfield or textarea in UIWebView

I am working on an iOS app with an UIWebview showing all the major content. All textfield or text area are able to bring up the virtual keyboard and input new text. However, if I want to tap on a previously entered word so I can edit that word, the cursor won't move to that location. Also, tapping and holding won't bring up the "magnifying glass" for selection / copy/paste.

I have been googling for two days already, all my textfields have the

-webkit-user-select:text

CSS setting already, and I have tried other CSS like

-webkit-writing-mode, cursor:auto, -webkit-appearance: textfield;

etc, but still couldn't work. Does anyone have similar issue and able to shed some lights on it?

Any help is appreciated!

Finally found out that it's a custom piece of code (listed below) that was added in our app to intentionally disable touch event when the input field is on focus, so that scrolling is disabled when keyboard is up, and so user is not able to scroll outside of the fixed position element in UIWebView.

$('select,input,textarea').on('focus',function(){
    document.ontouchstart = function(e){ e.preventDefault(); }; //disable touch
});
$('select,input,textarea').on('blur',function(){
    document.ontouchstart = function(){ return true; }; //enable touch
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM