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 boolean bLastTouchDidWander
(name is purely for example)
On a touch Down, you set bLastTouchDidWander
to 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 bLasTTouchDidWander
to true.
Then ,for the webView:shouldStartLoadWithRequest:navigationType:
message of the UIWebViewDelegate
, if bLastTouchDidWander
is true, don't follow the link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With