I am sure that this has been asked before but i am unable to get to a solution.
I have a UIWebView which is wrapped inside a UIView.
The web view loads HTML - Tapping on the HTML link results in certain action (Done. Detect the click in ShouldStartLoad and act accordingly).
Tapping anywhere else other than a link should result in another action - This is where i am having an issue. Just cant seem to get the tap gesture to work (on the UIWebView or the wrapper UIView)
Any clues?
Regards
Sid
Adding tap gesture recognizers is not an easy task due to the way it works internally (UIKit view hierarchy and WebKit view hierarchy).
I would suggest a much simpler solution. Add Hammer.js to your HTML (or inject it in webViewDidFinishLoad:), and on tap events, send a fake load request and catch like with links.
Hammer(el).on("tap", function() {
//Send fake request here.
});
Related
I am working on user interaction in different uiviews.
I know how to send user interaction on parent view or on it's specific UI components.
In my example, I am sending event to UIButton that is working properly even I tap on outside of UIButton bounds (Please take a look on attached code for more inside).
But I don't know that when I tapping on top view, UIButton TouchDown selector called but TouchUpInside not calling. Why is it happening?
Any suggestions? Any explanation is greatly appreciated!
Github code link: https://github.com/jackMac1811/iOSUIInteractionTest
All uibutton events carrying their own behavior which enables to execute its bunch of code according to it.
if you want to invoke both methods tapping on top view you should have to use touch up outside instead of touch up inside event
Here's a very useful link https://stackoverflow.com/a/11390048/4003548
Hope this helps ..
I am trying to programmatically make a 2nd tap occur on the screen a few seconds after the actual tap event occurs. For example, if I tap the screen in the bottom left corner...is it possible to then programatically make a tap occur at a specified set of coordinates a few seconds later (see image).
You don't need to do horrid things like overlaying invisible buttons and faking taps.
All you need to do is set your view controller to conform to the UIWebViewDelegate protocol, and implement the webView:shouldStartLoadWithRequest:navigationType: protocol method.
By implementing this method and checking for a link-tap event with if(navigationType == UIWebViewNavigationTypeLinkClicked) your app is now being informed of link-taps without intercepting and eating them via invisible buttons, so your web site doesn't miss out on being informed of the request.
You can then implement the necessary logic to change categories in JQuery on the site.
Is any possible ways that I would like to know before html content was shown in uiwebview.
coz when I called to some url, It will take a few seconds to complete the whole page loading. Before loading was completed, some of the content was already shown. I would like to know before that content was shown or before start showing.
UIWebView has a delegate protocol called UIWebViewDelegate. Two methods you should implement are – webViewDidStartLoad: notify monitoring object of when a site will about to load and – webView:shouldStartLoadWithRequest: notify when there a certain request like click, submit, back/forward etc are being made
I've been researching how to use a UIWebView embedded in a UIScrollView for a while now and cant seem to find an easy fix to my problem. I'm using a UIWebView because a UITextView, although allowing hyperlinks, does not allow you to change the link color from the standard blue apple sets.
But using a UIWebView introduces another problem: It blocks the UIScrollView it is embedded in from handling scroll events because a UIWebView handles these events within its own private implementation.
Although this allows me to use its embedded links, the UIWebView absorbs the touch events which doesn't allow me to scroll up/down when dragging within the UIWebView itself. I worked around this problem by placing a transparent UIView overlay exactly over the UIWebView, intercepting the touch events that it receives, and resigning it as first responder so that the UIScrollView that they are both subviews of can handle the scrolling appropriately.
Now, however, I can't seem to think of solution to the new problem this introduces: I can't click on the links within my UIWebView that is right under the UIView Overlay.
What is the best way to forward touch events to a UIWebView that is right underneath my transparent UIView in order to trigger my UIWebView's delegate method 'webView:shouldStartLoadWithRequest:navigationType:' for tapping on links?
FYI from UIWebView API doc:
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
Back to the question,
UIWebView has property called scrollView, try doing:
webView.scrollView.scrollEnable = NO;
I have a Webview (inside a view) and a toolbar which is hidden most of the time.
This is quite common behaviour for ipad magazines:
Tapping on the page will hide and display the toolbar, but the toolbar is hidden by default.
I am using shouldRecognizeSimultaneouslyWithGestureRecognizer
The behaviour right now does this:
- If the user taps the page (webview) it toggles the toolbar state using gesture recognizer
- if the user taps the page and there is an interactive element such as a weblink within the UIWebview, it responds to that interactive link but ALSO toggles the toolbar.
The desired behaviour is this:
- if the user taps the page on a non interactive area, it toggles the toolbar state
- if the user taps the page on an interactive area it ONLY responds to the webview interaction and does NOT toggle the toolbar.
Note there is an almost identical question here:
Gesture recognition with UIWebView
Even though it is marked as resolved if you read it through you will see the solution did not work for the poster and he is still getting a dual response when he (and I) want an either or response. I did try posting a follow up question but that was deleted probably because the moderator believed it was resolved
If the UIWebView, for whatever reason, catches the touch, you're not going to be able to get the UIGestureRecognizer callback as well. My only recomendation is to make whatever happens in the website when you tap on something execute some javascript, and then catch that Javascript. You can take this as an example.