UIScrollView子目录内容大小问题
我正在使用一个scrollView,其中我已经添加了一些静态内容在一个容器视图和下面这个容器视图我已经添加了一个Web视图,并将这两个视图添加到我的scrollView,我不希望Web视图滚动,而是我希望我的滚动视图应根据我的容器视图的高度和Web视图中内容的高度进行滚动。
注意:我正在加载webview中的内容作为htmlstring,我从服务器接收,内容来自html标签之间,然后我把这个string传递给web视图。
谢谢
试试这个代码
CGRect contentRect = CGRectZero; for (UIView *subview in scrollview.subviews ) { contentRect = CGRectUnion(contentRect,subview.frame); } scrollview.contentSize = CGSizeMake(scrollview.bounds.size.width, CGRectGetMaxY(contentRect));
将scrollview内容大小设置为containerview height + webview height
并且您的webview Height
必须等于content Size of that Webview
的content Size of that Webview
因为您不想滚动webview。
- 在webview中find内容的高度
- 使其成为webview,containerview框架和scrollview内容的大小
- 禁用webview的滚动