UIWebView: Cancel opening a link when a “touch” is outside the link?

I have a UIWebView with links in text that open Safari when clicked.

If the user touches the link, it gets dark ... but if he wants to cancel clicking on the link, first laying down his finger, it will remain dark, and release your finger anywhere, open the link.

Is there a way to allow the user to “cancel” his “click” by removing his finger - along the lines of the behavior of the “touch in” button?

+6
ios cocoa-touch uikit uiwebview
source share
1 answer

There is no way to do what you asked for using the public SDK.
The best answer I can come up with is touch tracking, started and touch events for UIWebView itself. Then add UIWebviewDelegate and to this delegate interface, add boolean bLastTouchDidWander (name, for example, is clean)

When you bLastTouchDidWander Down, you set bLastTouchDidWander to false.

At the UP touch, you measure how far the touch moves. If it has moved more than a certain amount, consider how to “touch outside” and set bLastTouchDidWander to true.

Then for the message webView:shouldStartLoadWithRequest:navigationType: UIWebviewDelegate , if bLastTouchDidWander true, do not follow the link.

+2
source share

All Articles