views:

50

answers:

1

I have an iPad app with two UIWebviews, one on top of the other. Is there a way to have all the links that are clicked in one, open in only the other view?

A: 

Use this in the delegate for your first UIWebView:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
        [otherWebView loadRequest:request];

        return NO;
    }

    return YES;
}
Douwe Maan
Is this a built in method of the UIWebView Class?
Liam
Oh, where should I place this method? I have an AppDelegate and a ViewController class only.
Liam
This is a method your `UIWebView` calls on the object you have set as its `delegate`. This method is specified in the `UIWebViewDelegate` protocol this object should use. Which of your two classes this is, depends on what you set as the `UIWebView` 's `delegate`.
Douwe Maan