简体   繁体   English

UIWebView内部UIScrollView Html链接不起作用

[英]UIWebView Inside UIScrollView Html Links Not Working

I have added a UIWebView along with some labels inside UIScrollView (using StoryBoards ) by adding it as a subview and then setting the ScrollView height to show all the html content of WebView that is loaded in it using loadHtmlString . 我添加了一个UIWebView以及UIScrollView一些标签(使用StoryBoards ),将其添加为subview ,然后设置ScrollView height以显示使用loadHtmlString加载到其中的WebView所有html内容。

The links in the html content are not working. html内容中的链接无效。 A little searching revealed that Apple does not recommend putting UIWebView inside UIScrollView to avoid unexpected behaviour. 一点点搜索显示Apple不建议在UIScrollView中放置UIWebView以避免意外行为。 But as i also have to add labels and other stuff other than the UIWebView , so i have to embed them inside UIScrollView . 但是,由于我还必须添加除UIWebView之外的标签和其他内容,因此我必须将它们嵌入到UIScrollView

Is there any way I can make the links work in the html content without violating and Apple's recommendation? 是否有任何方法可以使链接在html内容中工作而不违反Apple的建议?

There is no reason to put a UIWebView inside a ScrollView. 没有理由将UIWebView放在ScrollView中。 UIWebView will scroll and zoom and pan the content properly as is. UIWebView将按原样滚动,缩放和平移内容。 It is sort of redundant unless you have some other layout reasons for example combining it with some other views. 除非您有其他布局原因,例如将其与其他视图相结合,否则它有点多余。

The correct way to add your labels is to add them to a UIViewController or NavigationController and have them positioned around the UIWebView and to also add the UIWebView to that as well. 添加标签的正确方法是将它们添加到UIViewController或NavigationController中,并将它们放在UIWebView周围,并同时添加UIWebView。

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

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