简体   繁体   English

UIWebview 和 UIScrollview

[英]UIWebview and UIScrollview

I have a UIScrollview to allow for pagination, and a UIWebview on the detail views inside.我有一个 UIScrollview 允许分页,还有一个 UIWebview 在里面的详细视图上。 I know you are not supposed to do that according to Apples Class Reference, but I don't see another option.根据Apples Class Reference,我知道您不应该这样做,但我没有看到其他选择。

In order to make responses and experience a bit better, I disabled scrolling of the Webview, with:为了做出更好的响应和体验,我禁用了 Webview 的滚动,其中:

[[[webView subviews] lastObject] setScrollEnabled:FALSE];

But now I am looking for a solution to make the webview the right size, depending on the content.但现在我正在寻找一种解决方案,使 webview 尺寸合适,具体取决于内容。 Is there an easy way to do this, where the width of the webview stays the same, but the height grows (automatically) when that is required to show the full article?有没有一种简单的方法可以做到这一点,webview 的宽度保持不变,但是当需要显示完整文章时高度(自动)增长? This will remove the scrolling problem, as it sit he scrollview who will take care of all the scrolling in this scenario.这将消除滚动问题,因为它位于滚动视图,他将负责此场景中的所有滚动。

Does that make sense?那有意义吗?

Sure - this isn't that uncommon a scenario (needing to figure out the entire height of a UIWebView so you can size it's frame to avoid the web view itself scrolling, such as when a web view is in a table view, or parent scroll view).当然 - 这种情况并不少见(需要计算出UIWebView的整个高度,以便您可以调整其框架的大小以避免 web 视图本身滚动,例如当 Z2567A5EC9705EB7AC2C984033E 中的 Z2567A5EC9705EB7AC2C984033E 视图本身滚动时看法)。

You should refer to this answer: How to determine UIWebView height based on content, within a variable height UITableView?您应该参考这个答案: 如何根据内容确定 UIWebView 高度,在可变高度 UITableView 内?

Which will basically answer your question.这基本上会回答你的问题。 You create your scroll view, load in the content, run some javascript to get the full height, and then adjust the web view frame to reflect the full height of the content.您创建滚动视图,加载内容,运行一些 javascript 以获得完整高度,然后调整 web 视图框架以反映内容的完整高度。

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

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