0

I am working with UIWebView, in the detailed view of my app, I open a url into a webview and embed the webview into my detailed view(which is a uiview). Now the content of the embedded webview has web links, which when clicked open up into the same embedded webview, as should be expected.

The concern for me here is that I want to open the second level links(links clicked from within the embedded webview) into another customized webview component, not into the same embedded webview.

I tried implementing the following method of the UIWebViewDelegate, but I could not achieve the desired result.

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

Implementation:

{
CustomWebView* iWebView = [[CustomWebView alloc] initWithFrame:CGRectMake(0, 0, webView.frame.size.width, webView.frame.size.height)]; //creating custom webview in same frame
    [iWebView loadRequest:request];//loading the request into custom webview
    [webView addSubview:iWebView]; // adding custom webview overlapping the webview
    return NO; //[stop loading the url into the embedded webview]
}
Xcodian Solangi
  • 2,342
  • 5
  • 24
  • 52
user1242321
  • 1,578
  • 2
  • 18
  • 30

1 Answers1

0

You also need to set your Custom Web View delegate:

iWebView.delegate = self;

Then you should see that the request will first pass through the

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

delegate method.

Lefteris
  • 14,550
  • 2
  • 56
  • 95