0

I am currently embedding a UIWebView inside a UICollectionViewCell to be able to view HTML formatted text residing in my local data structure.

I know it has been stated many times one should not embed an UIWebView inside a scrollView, but i currently see no other way to achieve displaying mixed content overviews (That is the current requirement, and so far UICollectionView does work very well with large data sets).

The Problem is, that i am not able to call the UIWebViews Delegate method:

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

I need the delegate method to be able to display external links or call local methods.

Is there a way to achieve this? Maybe by handing over the events programatically?

crud21
  • 127
  • 1
  • 10
  • 1
    Are you 100% sure that you set the delegate of the web view? – Mick MacCallum Jan 13 '13 at 14:59
  • 1
    Have you set the delegate of the webView in your code?: `self.webView.delegate = self;` – Lefteris Jan 13 '13 at 15:00
  • The only delegate method that is called is: `-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { ... }` – crud21 Jan 13 '13 at 16:08
  • Yes, i did set the delegate in `cellForItemAtIndexPath:(NSIndexPath *)indexPath` with `UIWebView *webviewField = (UIWebView *)[cell viewWithTag:10]; [webviewField setDelegate:self];`. The webview is already added via Interface Builder. – crud21 Jan 13 '13 at 19:14

1 Answers1

0

Thanks for the feedback!

I just found out what i did wrong:

I just needed to update the cells' contentView: [[cell contentView] setFrame:frameContainingWebViewSize]

That did the trick. The delegate method was not called because the contentView did not cover the webview (clipSubviews is set to NO) and thus the tap events where not fired.

crud21
  • 127
  • 1
  • 10