Is there a way, in iOS, to write code that is called when the system is about to display the text selection controls on a UIWebView?
I need some of my code to be called when the user wants to select something, but before the selection is actually added to the page, if possible.
I found a way around this using delayed method calls. The selection controls do not appear immediately, but only after you tap and hold over some text for about half a second.
Here’s a rough outline of the code I used to do that:
Not the best solution, but it works in my situation. The delay can be tweaked if textSelectionWillAppear: needs more time to run, but I would think the delay shouldn’t get too close to 0.5f or the method may not actually get called before the selection box appears.