【问题标题】:How to set UIScrollView content size for AutoLayout enabled UIVIew如何为启用自动布局的 UIVIew 设置 UIScrollView 内容大小
【发布时间】:2013-07-26 05:43:32
【问题描述】:

我在我的一个 UIView 中使用自动布局功能,根据文档,我没有为 iPad 和 iPod 创建单独的 xib,我已经为 iPad 创建了一个 xib,并尝试将其用于具有自动布局功能的 iPod,一切正常,但是我使用的滚动视图的内容大小与 iPad 相同,因此它向下滚动很长时间,我附上了图片以供参考,请检查并让我知道如何处理这种情况。

注意:这里的问题是我无法为 AutoLayout 调整大小的视图大小。

感谢您的时间:)

【问题讨论】:

    标签: iphone ios autolayout ipod ipod-touch


    【解决方案1】:

    设置压缩:

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone )
        {
           // set your  requirement size
            [yourscrollview setContentSize:CGSizeMake(320, 600)];
        }
        else
        {
          // set your  requirement size
           [yourscrollview setContentSize:CGSizeMake(768, 1100)];
        }
    

    【讨论】:

    • 我试过了,还是不行。我想,问题是这里的视图大小更大,所以内容大小设置没有考虑在内。由于我使用的是 Autolayout,所以 setFrame 也不适用于 UIView。
    猜你喜欢
    • 1970-01-01
    • 2013-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 2012-09-27
    • 1970-01-01
    • 2012-05-18
    相关资源
    最近更新 更多