views:

229

answers:

1

I have a view controller and I am intercepting the touches on links within the web views it manages.

My main view controller has this method.

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

{
    //I can see this request come in upon a touch
    NSURL *url = request.URL;
    NSString *urlString = url.absoluteString;
    NSLog(@"raw: %@", urlString);

    //do some stuff (like figure out what capturedFilename is) 
    ExplainViewController *explanation = [[ExplainViewController alloc] initWithNibName:@"ExplainViewController" bundle:nil file:capturedFilename];
    [self.navigationController presentModalViewController:explanation animated:YES];
}

And this loads a modal view properly.
ExplainViewController has a webView itself. When a user touches a link within ExplainViewConroller I'd like to handle that request too (and present another modal view).

ExplainViewController has this but I get no log activity from either method (the following nor the previous):

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType 
{
    NSURL *url = request.URL;
    NSString *urlString = url.absoluteString;
    NSLog(@"raw: %@", urlString);
}

I want to know where this link touch request is going and how I can intercept it.

Both mentioned view controllers are using this in their .h <UIWebViewDelegate>

+2  A: 

You mention that both view controllers conform to the UIWebViewDelegate protocol, but is the delegate outlet of the UIWebView in the nib for ExplainViewController.h set to an instance of ExplainViewController. It will not call the method unless the UIWebView delegate property is set.

Brandon Bodnár