Search code examples
objective-cuiwebviewuiwebviewdelegate

Multiple UIWebViews, how do I track webViewDidFinishLoad for both?


I've tried:

- (void) webViewDidFinishLoad:(UIWebView *)webView1{

}
- (void) webViewDidFinishLoad:(UIWebView *)webView2{

}

Errors are that I can't redefine the same method.

If I have to use the same method, I need to figure out some way of identifying one webView from the other, how would I do this?

Cheers


Solution

  • - (void) webViewDidFinishLoad:(UIWebView *)webview{
         if ( webview == self.webview1 )
         {
              // in case of webview 1
         } else if ( webview == self.webview2 ) {
              // in case of webview 2
         } else {
              NSLog(@"webview %@ was not wired to a property of %@",webview,self);
         }
    }
    

    and add webview1 and webview2 as properties to your controller. (i.e. you need the @property line and a @synthesize line)