-1

I'm building a simple iOS app with UIWebView. Inside the Web View I'm loading a request with URL of a specific page. This page redirects me into another page and I'd like to execute a method when the redirect happens.

So basically I'm looking for a solution which would help me discover when another request is called so I can execute a method every time it happens. I couldn't find any event like this in Apple Documentation so I was thinking if you could help me with it? It should work with hyperlinks, redirects, etc.

Regards, avi

Larme
  • 24,190
  • 6
  • 51
  • 81
avi
  • 43
  • 1
  • 8

2 Answers2

0

Nevermind,

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

does the trick, just customize the request to fill your needs.

avi
  • 43
  • 1
  • 8
0

You need to learn about the UIWebViewDelegate protocol.

https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebViewDelegate_Protocol/index.html

Specifically this method will be of interest.

- (BOOL)webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
 navigationType:(UIWebViewNavigationType)navigationType
Albin Stigo
  • 2,082
  • 2
  • 17
  • 14