UIScrollView 子视图内容大小问题 [英] UIScrollView subviews contents size issue

查看:23
本文介绍了UIScrollView 子视图内容大小问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用滚动视图,其中我在容器视图中添加了一些静态内容,在此容器视图下方我添加了一个 Web 视图并将这两个视图添加到我的滚动视图中,我不希望 Web 视图滚动,相反,我希望我的滚动视图应该根据容器视图的高度和 Web 视图中的内容高度滚动.

I am using a scrollView, in which i have added some static content in a container view and below this container view i have added a web view and added both these views into my scrollView, I dont want the web view to be scroll, instead I want that my scrollview should scroll according to the height of my container view and height of contents in web view.

注意:我正在将 webview 中的内容加载为 html 字符串,这是我从服务器接收的,内容位于 html 标签之间,然后我将其作为字符串传递给 web 视图.

Note: I am loading contents in webview as html string, that i am receiving from server, The contents are coming in between of html tags and i am then passing this as a string to web view.

谢谢

推荐答案

试试这个代码

  CGRect contentRect = CGRectZero;

  for (UIView *subview in scrollview.subviews ) {
    contentRect = CGRectUnion(contentRect,subview.frame);
  }

  scrollview.contentSize = CGSizeMake(scrollview.bounds.size.width, CGRectGetMaxY(contentRect));

这篇关于UIScrollView 子视图内容大小问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆