ORStudios
ORStudios

Reputation: 3233

How to detect when UIWebView changes page?

How can I detect when a UIWebView changes a page? At the minute I am using

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

but this not only detects the page change but also each request on the page.

I am trying to get it so that when the user clicks on a link it detects the click and then I can see what the url is that the user is trying to see.

Any ideas?

Thanks

Upvotes: 0

Views: 1733

Answers (1)

gro
gro

Reputation: 755

So, you could interrogate navigationType ... defined as ...

enum {
   UIWebViewNavigationTypeLinkClicked,
   UIWebViewNavigationTypeFormSubmitted,
   UIWebViewNavigationTypeBackForward,
   UIWebViewNavigationTypeReload,
   UIWebViewNavigationTypeFormResubmitted,
   UIWebViewNavigationTypeOther
};
typedef NSUInteger UIWebViewNavigationType;

... and act accordingly, and/or look into the request for any particulars ...

    NSURL *url = [request URL]; or NSURL *url = [[request URL] absoluteString];

Upvotes: 1

Related Questions