iPhone UIWebView initial focus? - iphone

I have a simple app with a full screen UIWebView. This contains HTML generated by the app. I respond to clicks on various elements of the page via document.location = "someCommand"
I have to touch the screen once before it will respond to a second touch. It's almost like it is not the focused control.
It is the only view in the app.
How can I ensure that the first time the UIWebView is touched it responds?

I think you should simply set it as the firstResponder when your view controller is put on the screen.

Related

Loading screen is not working properly

In my app I am showing loading screen when request is sent to server and when response is received I am removing that loading screen.
To display loading screen I used UIView and reduce its alpha to 0.5 so that it shows the background view.
My problem is user is able to click button displayed on background view when loading screen is still visible.
What I want is: User should not be able to click anywhere on the screen when loading screen is visible. Even though I made userInteractionEnabled false for UIView but still user is able to click on button, why?
If any one knows where I am doing wrong and how I can achieve this, please let me know.
Thanks in advance!
The UIView may have interaction disabled but if the button is higher on the view hierarchy then its on TOP of the view so it's still accessible.
If this is a view made in the nib then make sure its at the top of the view stack
Or if its programmatically then add it as a subview at the end of the function or add it mainWindow (be VERY careful adding things to main Window, this is the top of the hierarchy)
Like wise the utility open source library available.
iOS open source project is MBProgressHUD,
it refers to Heads Up Display, a view that is overlayed on another view, typically to show an activity indicator and/or offer a means to interact with the UI. A good example of an HUD is when playing a movie with the built in movie player. When you tap the screen, the movie player will show a series of controls on the display. Another common example, and one that is pertinent to MBProgressHUD, is showing progress indicators on top of an existing view. For example, when accessing a remote service, to provide feedback to the user you may opt to display a “Please Wait” message
you can download the source code from here.
Yes I got it, I did userInteractionEnabled false for UIView so the click event was sent to the button which was on main view.I removed userInteractionEnabled false and it is working fine.
You can use [[UIApplication sharedApplication] beginIgnoringInteractionEvents] when you are sending request to server & shows loading view.When you receives the response call [[UIApplication sharedApplication] endIgnoringInteractionEvents] & remove the loading view.

UIKeyboard pushing UIWEBVIEW

Currently the way ios handles input fields in the uiwebviews is by pushing the uiwebview up when u tap on the input field in a uiwebview. Sometimes, the uiwebview goes outside the page. I was wondering how the whole things work? My parentviewcontroller doesn't have any scrollview inside etc.. but yet it pushes the uiwebview up.
Any idea how I can prevent the keyboard from pushing the uiwebview up. How does it know by how much it needs to push up. I added a method to get the information about the keybaord when it shows up and the size of the keyboard which is returned is 1024px for the height which is really weird.
Thanks.

Can we add UIbuttons, uilabels on to webview and make them scrollable along with the web view in iPhone?

I was working on webview. I am facing an issue where I want to display html as well as UIbuttons.
I made webview added Ui butons but when I scroll webview the webview scrolls but the uibuttons remain at the same location.
I've not actually tried this, but in theory this should be possible on iOS 5. If you just add the button to the UIWebView it won't work - as you'll find, when you scroll the views you add remain in place. In iOS 5 Apple added the scrollView property to UIWebView, so if you add your views to that instead (the scroll view) you may find it works?

How to show loading of content from YouTube?

I have a UIViewController with a UIScrollView inside it. This scroll view contains a few strings and images, and more recently it's own UIWebView which contains a YouTube video.
As a first case, assuming the user has Internet access, how should I show the user that the box contains content that is currently loading?
Musings:
I was able to place a UIView on top of this UIWebView (within the scroll view) which contained a UILabel with the text "Loading..." inside it. But I was unable to remove/hide the label based on when the video has fully appeared as I could not get viewDidAppear et al to respond. I also have access to a BOOL which tells me if the user has Internet access or not, so the other side to the question would be to set the same label to explain that they have no web access if that is true. (which would explain the presence of a white box in this scroll view)
I also looked at whether it'd be possible to write a custom responder to fire off when the video thumbnail in the web view had finished loading, but again I couldn't get any of the responder methods to be hit for this to work.
In short, how should I be tackling this problem? Thanks in advance for any advice or assistance.
Set your view controller as the web view's delegate. The UIWebViewDelegate protocol defines two methods, -webViewDidStartLoad: and -webViewDidFinishLoad:, that you should be able to use to track when the page has begun to load and (hopefully) when the thumbnail has appeared.

iPhone UIWebView touch cause Toolbar to appear

I am trying to have a UI which is a full screen UIWebView. When the view is touched the tool bar appears.
I can do everything but get the touchend event in the UIWebView. I have tried putting a UIColor.Clear'd UIView ontop and catching TouchEnd there and passing it on, but would like a better solution.
I understand that we are not supposed to subclass the UIWebView from the docs.
Ideas?
I found a better solution. Simple have the HTML in the UIWebView send a message to the client via a document.location = "SomeCommandName"
Then catch this in code and toggle the view as needed.
Much simpler.