RayChen
RayChen

Reputation: 1468

how to get UIPopoverController from UIWebView

I load a webpage in a uiwebviewcontroller,after click one link, it will pop a popovercontroller, is it possible to get this controller in my code?

Actually, this popovercontroller is not created by my code. The html detect the webpage is loaded by iDevice and pop this. That means, if I use safari to open webpage, it also will display this popovercontroller.

Thanks.

Upvotes: 0

Views: 158

Answers (1)

Rocker
Rocker

Reputation: 1269

implement the UIWebView delegate method.

  -(BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
   {
       NSURL *url = request.URL;
       NSString *urlString = url.absoluteString;
       if([urlString isEqualToString :@"abc.com") // link on which want to open popoverview 
       {
           UIPopoverController  itemPopover = [[UIPopoverController alloc] initWithContentViewController:viewController];
          [itemPopover presentPopoverFromRect:customCell.addImage.bounds inView:webViewpermittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

            return NO; //if wanted to load the link on UIWebview return YES else return NO
       }



        return YES;
    }

Upvotes: 1

Related Questions