Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide text selection handles after action in UIWebView

I have several custom UIMenuItems that do things with a selection in a UIWebView. After the action has been run on that selection I want to hide the selection handles just as copy: does.

I have tried using window.getSelection().removeAllRanges(); and that works in that window.getSelection() no longer returns anything but the text selection handles stay visible.

Is there a way to remove the selection and the handles with it?

Edit: I don't need it to be a JS solution but I can't loose the state by reloading the webview.

like image 334
Matthew Leffler Avatar asked Aug 22 '10 16:08

Matthew Leffler


1 Answers

Just disable and re-enable the User Interaction:

myWebView.userInteractionEnabled = NO;
myWebView.userInteractionEnabled = YES;
like image 185
Sylter Avatar answered Oct 30 '22 03:10

Sylter