I have a UIWebView with links in the text which open Safari if pressed.
If a user touches a link, it darkens…but if he wants to cancel pressing the link by moving his finger away first, it stays dark, and releasing the finger anywhere opens the link.
Is there some way to enable the user to “cancel” his “click” by moving away his finger – along the lines of the behavior of a “touch up inside” button?
There’s no way of doing exactly what you asked using the public SDK.
The best answer I can think of is to track touch began and touch ended events for the UIWebView itself.
Then, add a
UIWebviewDelegate, and to this delegate’s interface, add a booleanbLastTouchDidWander(name is purely for example)On a touch Down, you set
bLastTouchDidWanderto false.On a touch UP, you measure how far the touch moved. If it moved more than a set amount, consider this a “touch up outside”, and set
bLasTTouchDidWanderto true.Then ,for the
webView:shouldStartLoadWithRequest:navigationType:message of theUIWebViewDelegate, ifbLastTouchDidWanderis true, don’t follow the link.