简体   繁体   English

UICollectionViewCell中的UIWebView不调用Delegate方法

[英]UIWebView inside UICollectionViewCell does not call Delegate Method

I am currently embedding a UIWebView inside a UICollectionViewCell to be able to view HTML formatted text residing in my local data structure. 我目前正在将UIWebView嵌入UICollectionViewCell内,以便能够查看驻留在本地数据结构中的HTML格式的文本。

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). 我知道已经说过很多次了,不应该在滚动视图中嵌入UIWebView,但是我目前看不到其他方法来显示混合的内容概述(这是当前的要求,到目前为止,UICollectionView确实可以很好地处理大型数据集)。

The Problem is, that i am not able to call the UIWebViews Delegate method: 问题是,我无法调用UIWebViews Delegate方法:

- (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? 也许通过编程方式移交事件?

Thanks for the feedback! 感谢您的反馈!

I just found out what i did wrong: 我只是发现自己做错了什么:

I just needed to update the cells' contentView: [[cell contentView] setFrame:frameContainingWebViewSize] 我只需要更新单元格的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. 没有调用委托方法,因为contentView没有覆盖Webview(clipSubviews设置为NO),因此没有触发tap事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM