views:

387

answers:

1

So I am creating a web browser for iPhone for my class and I am having an issue where whenever I submit a form-like thing from a website, it doesn't update my address bar text (which is a UITextfield). As an example, if I go to google.com on my browser and so a search for something in the search field and hit submit, it loads a new page without changing my address bar (it's still on google.com). I have it to change for links, but I don't see how to make it so it works for forms like this. I added a NSLog in my webViewDidFinishLoading function and it doesn't say the page is loading, so I'm not sure how to detect when it changes this way. Does anyone have any ideas why it's not working?

A: 

Intercept it in this method instead:

- (BOOL)webView:(UIWebView *)webView
        shouldStartLoadWithRequest:(NSURLRequest *)request
        navigationType:(UIWebViewNavigationType)navigationType;

The navigationType can be UIWebViewNavigationTypeLinkClicked , UIWebViewNavigationTypeFormSubmitted or others. And [request URL] will be an NSURL object with the page URL about to be loaded.

Squeegy