iOS release a touch event to load data into a UIWebview - ios

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.

Related

How to make iOS keyboard appear/stay up during entire app lifecycle?

I want to know how to make the keyboard appear in an iOS Swift app and remain there permanently. I know it appears when the user touches inside a textfield. That's not what I want. I want it to be there when the user loads up the app and to stay there permanently. I do still want the keyboard to communicate with a textfield as it normally would.
I would also like to be able to use the keyboard in storyboard auto layout and scale/align my buttons around the keyboard, which is asked here:
Xcode storyboard layout size simulation - keyboard up?
What I tried:
If I could simulate a "touch" inside a textfield programmatically I think I can accomplish my task. I would forcibly simulate a "touch" once the app loads and then in the "textFieldShouldReturn" method I can repeat the forced programmatic touch inside the textfield to prevent the keyboard from disappearing. (This may cause the keyboard to disappear and then reappear quickly, which would be ugly and undesirable.) How do I force this fake touch?
In Conclusion:
I am using iOS Storyboard and Swift.
How do I cause a keyboard to load up on start up and remain there even after pressing return/send?
If the above is impossible, how do I programattically force a touch inside a textfield?
I think that you can't do this from storyboard side, but from code side, assuming that you name your textfield "textField", you can do self.textField.becomeFirstResponder() on your viewDidLoad() in order to make the keyboard appear when you enter on this screen. This should keep the keyboard on screen unless you do resignFirstResponder() elsewhere.

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.

UISearchDisplayController's full-screen background intercepts touch events in iOS 7

I have a UITableview that doesn't take up the whole screen (screenshot). Everything worked fine in iOS 6. But in iOS 7, when the user searches, the search result table takes up the whole view (screenshot).
To fix this, I tried setting the frame manually as described in this answer. The appearance is now correct (screenshot), but now the "<" button in the top left doesn't receive tap events when the search results table is displayed.
It seems the searchResultsTableView is adding a full-screen background view that is intercepting touch events. To prove this, I added this code to didShowSearchResultsTableView:
controller.searchResultsTableView.superview.backgroundColor = [UIColor blueColor];`
This screenshot confirms my hypothesis.
How can I fix this to allow the "<" button to receive tap events?
I want to avoid modifying controller.searchResultsTableView.superview so that my change doesn't break in future versions of iOS.
And what change in iOS 7 caused this behavior to start happening?
I am still searching for a better solution, but currently my solution is in the viewControllers viewDidLayoutSubviews tell your view to move to front. The code would look something like this.
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self.view bringSubviewToFront:self.navigationBar];
}

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.

Content Editable UIWebView scrolls and overlaps over the button/images of uiview in 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.

Resources