I am implementing an in-app browser using UIWebView, that shows an 'action' button up-top that - when tapped - scales the UIWebView and allows the user to perform some other actions.
If, however, at the point of tapping this 'action' button, the user were entering some text on the webview, or using a picker to select an option from a drop-down list, then the webview gets scaled without dismissing the keyboard/picker. Apart from being ugly, this also obscures my main view and controls.
So is there a way to make a UIWebView dismiss all associated input controls, such as keyboards/pickers, when asked to?
I tried using [myWebView resignFirstResponder] but that didn't work. Any ideas? Thanks.
Was able to do this by using
[myWebView endEditing:YES]
Related
I'm opening an UIWebView from my iPad Application as a PresentModalViewController and opening google maps "http://maps.google.com/maps?q=London" , everything is working fine but the only problem is when i search places source and destination and click on arrow button the keyboard is not resigning, but it is working fine when i open it in safari.
How to resign my keyboard when i click arrow button inside UIWebview?
Any help is thanks in advance.
I would suggest implementing delegate UIWebViewDelegate and catching the event when the page is being reloaded. I am not sure which arrow button you mean, but I believe that when you click that button the UIWebView loads the previous web page. At that point webViewDidStartLoad should be called, in which you can try to call resignFirstResponder on UIWebView.
I want to implement this on my app. I want to search for tutorials on this topic but I don't know what its called. Can someone please tell me what its called? Eg. In the photos app in iPhone, when u click on the left most button at the bottom, a screen pops up from the bottom giving you options to either email image, set as wallpaper etc.. So, once again, what is this called? Thanks
That is a UIActionSheet. Check out the UIActionSheet Class Reference.
Basically you create one with the designated initializer -initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: then send the -showInView: message to display it. You'll have to set yourself as it's delegate in order to handle selections made by the user.
The button is the 'action' barButtonItem type.
The button then opens a modal sheet. Opened with something like:
[self presentModalViewController:menuViewController animated:YES];
I have a UIWebView controller that loads a web page and I would like to add some kind of a bar at the top of the page with refresh and close buttons.
The bar should hide when the page loaded and should show again if the user taps the top part of the page.
Does anyone know how to approach it? Is there any simple way to do that?
UPDATE:
I think I wasn't clear enough with the question, so here are some clarifications:
1. The applications is a standard application that one of the flows opens UIWebView that loads a web page
2. What I'm looking for is a bar that will slide down on top of the web page (loaded in UIWebView) and should help the user overcome a scenario where the web page is not loaded for some reason
3. The bar should hold the back (just close the UIWebView) and refresh (reload UIWebView) operations.
Hope it helped.
Thanks,
Shimix
I'm working on something like this right now and so far, here's what I've come up with. Some of this may be obvious, but important:
Your address bar should be the left navigationItem.
The search bar is the rign navigationItem.
You should animate a cancel button in/out when beginning/ending editing in the URL box.
Safari Mobile uses the Prompt property of the navigationBar to display webpage titles.
To animate the widths of the search/URL bars, use UIView animation when the bar is selected.
It's pretty simple to add a UIToolbar above the webview with UIBarButtonItems that call the webview's refresh, back, and forward methods. You can also add the webviewdelegate methods to your view controller to detect when the page has finished loading and hide/show the toolbar that way.
If you want the refresh and navigation controls to be displayed as part of the html content of the webview itself, that's a littler tricker, but not impossible. You can use the webview's shouldLoadRequest delegate method to detect that those buttons have been tapped, and then take the appropriate action within your viewcontroller. Hiding and showing the nav bar would have to be handled in javascript.
Unless I'm missing a library/project doing this, I don't think there is a simple way to do this.
I have already coded something similar to Safari mobile address bar, and from memory, it involved using private apis and/or playing with the "not so private but use at your own risks" UIWebView subviews hierarchy...
This is my first post and I have looked all over for a week or so now so I'm not sure if there is an answer out there or not.
I have an iPhone application (my first one) that has a view that includes a UIWebView.
The view responds to the shake gesture and then loads a modal view controller that includes navigation buttons for the webView that depend on whether the webView can go back/forward etc.
The problem is that the shake gesture works fine most of the time but, depending on what is displayed in the webView, the shake sometimes fails to register, whenever it fails I just have to locate and tap on a blank area of the UIWebView or click on the top navigation bar and shake again and this will usually register.
What can be causing this? Is it something to do with UIWebView?
OK, well i've found the solution for this.
Add the following code to the view that contains the UIWebView
[self becomeFirstResponder];
i chose to put this at the very end of the - (void)webViewDidFinishLoad:(UIWebView *)webView method
This seems to work OK on the testing i've done so far.
The scope of this question is IPhone 3.1 sdk (app running in simulator still)
I have a table view that has a cell with a UITextField in that cell. The table view is grouped, and has one section with just a couple fields. Im NOT using IB so backgroundTap is out of the question (as far as i can tell at least). When i click the text field, keyboard shows. Hiding it is still troublesome. Ive pulled the UITextFieldDelegate into the mix to hide the keyboard but the textFieldShouldEndEditing method doesnt seem to fire when the background is tapped (when i mean background, im tapping outside of the grouped table view section). First off, should it?
textFieldShouldReturn fires with no problem and i can resign at this point but shouldnt i be able to resign if focus shifts away from that control?
Any help is much appreciated
-me
Generally you'll only stop editing a field when you:
hit the "Done" or action button on the keyboard
begin editing another field
exit the view
have another button on screen that removes focus
From any of these, you can call -[textField resignFirstResponder] to dismiss the keyboard and call your -textFieldShouldEndEditing: method. There's no reason that just tapping on a non-active part of the screen should dismiss the keyboard.