Content Editable UIWebView scrolls and overlaps over the button/images of uiview in iOS - ios

I have a view with few buttons and UIWebView which loaded content editable HTML.
In UIWebView i am inserting images/Canvas using both native and javascript functionality.
Since the WebView is editable whenever webview is clicked keyboard comes up. Now when we are inserting/editing a image/canvas keyboard should hide. So for that i am checking for tap event, getting the id of the element at that position and hiding the keyboard if that is a image/canvas using [webview endEditing:YES];.
Now the problem what i am facing is that if i add 2-3 images and then clicks on the webview, webview starts moving from its position and overlaps the button/images kept at the uiview. So the button are not visible and i am not able to perform the actions related to that.

Issue resolved. I was using some kind of animation when the keyboard was show/hidden. Once i removed that uiwebview doesn't moves.

Related

Button Responsiveness at UIScrollView

I am dynamically creating a uiscrollview and i place some uiview's that contains some label and buttons inside to display some news. Every button inside the sub uiview calls a rest function to like, unlike or share the news. Some of the buttons opens overlay screens like comment news. I am assigning actions to buttons inside the main form that contains the uiscrollview.
When i click a button that opens an overlay screen. When i close the overlay screen and hit Like button, it does not respond to touches. After attempting one or two more times, it works.
Does anyone has any idea about this issue?
Are you using UITapGestureRecogniser for "Click action"? If yes, you propably want to set flag "cancelsTouchesInView = NO" for this recogniser.
Check to see if there is a clear view covering your button. That view will consume your tap, so the button never sees it.

How to create a clickable button when it is below another view? (iOS)

My ViewController contains WebView and invisible button over (or below) the WebView. (see image). I want that the button to be clickable. But(!) in the case there are some links in the WebView, the links should be clicked, not the button.
How can I do it?
Similar issue discussed here:
Add UIButton in a UIWebView
However, in my case, I need links that are clickable also not be scrolling enabled.
If all you need is to be able to still drag the UIWebView around while still being able to receive a button press on a certain part on the view, you don't need to place a button below it in order to achieve that.
UIButton can still be able to receive touch even if it is completely transparent.
yourButton.backgroundColor = [UIColor clearColor];
[yourButton addTarget:self action:#selector(pressed)forControlEvents:UIControlEventTouchUpInside];
This way the button would only receive the press and will not affect your dragging of the web view - it will ignore the dragging but respond only to the press.
Tested on a scrollable view with a clear UIButton.
Hope this helps.

Keyboard covers the whole UIWebView

I am making an iPad app and I have 3 small UIWebViews on the view. I have realized that if there is an HTML input field and I tap on it, Keyboard appears and covers one of the webviews. I can move up the web view but how can I detect which webviews' input field is tapped?
I would say use TapRecognizer active on the whole view. Using tap recognizer, find the location where it is tapped.
Now based on location I believe you can tell which webview is tapped.
Based on which webview is tapped, you can shift view upside.
Hope this will do the trick.

How can you handle touching a link within a UIWebView when you have a UIView overlay directly on top of it?

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;

iOS release a touch event to load data into a UIWebview

I have a UIWebview that is scrollable and loads text from an array. They're previous and next buttons to allow the user to get the last or next content.
If a user holds down the scrollable content of the UIWebview and taps next, the text in the UIWebview will not load the next data until the user releases their finger from the screen.
How to I cancel the touch from the screen momentarily when the user taps the previous or next buttons.
Thanks :-)
Usually, switching off and back on a gesture will force it to cancel.
Edit: I was on my cellphone before, so I'll just add more details to my answer.
If your using iOS 5 and up, you can probably try something like this in your button action (I'm not on a Mac right now so I didn't test):
- (IBAction)yourAction:(id)sender {
[webView.scrollView setScrollEnabled:NO];
[webView.scrollView setScrollEnabled:YES];
//The rest of your code...
}
The reason I'm saying iOS 5 and up is because before iOS 5, the scrollView of a UIWebView wasn't exposed. If you're not using iOS 5, you have to resort to iterating through the subviews of your webView to find a UIScrollView.

Resources