0

I am facing an issue while loading a UIWebView.I have a webview(1st) where a url is loaded.when that page is loaded,I am creating a small view which has webview (2nd) on top of the first webview,which is loading a second url.Basically I am loading a webview inside a webview.On click of a url in the second webview,the resulting url has to open in safari,outside the app. IF i am not setting [webview setDelegate:self],then the page is loaded in the small webview as intended but on click,nothing is happening..

However if i set delegae of second UIWebView as self,the url which needs to be loaded in second UIWebView is getting loaded in first url.

Has anyone done this kind of webview loading earlier. Please help.your help is deeply appreciated

Thanks

Loukas
  • 616
  • 1
  • 6
  • 22
dead_soldier
  • 429
  • 1
  • 5
  • 18
  • Can you paste your code here? I think you can set self as delegate to both webviews, then handle how the links should open with the delegate methods (you can differentiate whether the call is from which web view by storing a weak reference to both web views and compare). – nhahtdh Jun 12 '12 at 09:40
  • Sounds like your delegate methods are getting confused over which webview should be the one to handle a request; you can set the tag property (NSInteger) of a UIWebView to identify which is which. – Luke Jun 12 '12 at 09:42

1 Answers1

0

In your current class, you should test wich UIWebView delegate is dealing with First set:

webView.delegate = self;

then in shouldStartLoadWithRequest:

//UIWebView *smallWebView;
//UIWebView *mainWebView;
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
     if(webView == smallWebView
     {
         //Load stuff on safari
     }
     else
     {
         //This means that link was pressed in the mainWebView
         //Depending on your logic, you will load the smallWebView 
     }
}
Ruben
  • 9,056
  • 6
  • 34
  • 44
Omar Abdelhafith
  • 21,163
  • 5
  • 52
  • 56