即使设置了内容大小,UIScrollView也不会滚动 [英] UIScrollView will not scroll, even after content size set

查看:81
本文介绍了即使设置了内容大小,UIScrollView也不会滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UIScrollView是一个~4500px的水平视图,用户需要水平滚动才能查看内容。

My UIScrollView is a ~4500px horizontal view that the user needs to scroll horizontally through to view the content.

我已将其设置如下:

- (void)viewDidLoad
{

    [super viewDidLoad];

    sview.frame = CGRectMake(0, 0, 568, 320);
    sview.contentSize = CGSizeMake(4500, 320);
    [sview setScrollEnabled:YES];
}      

然而滚动视图什么都不做。我错过了一些明显的东西吗?我已经尝试过网上的每个教程。

Yet the scroll view does nothing. Is there something obvious I missed? i've tried literally every tutorial on the web.

推荐答案

我遇到了类似的问题。我做了以下修改并且scrollView开始为我滚动:

I got similar issue. I did following modifications and the scrollView started scrolling for me:


  1. 选择以检查UIScrollView
    中的'Bounce Horizo​​ntally'属性厦门国际银行。

  2. 将以下代码移动到viewDidAppear而不是
    viewDidLoad:




-(void) viewDidAppear:(BOOL)animated
{

    [super viewDidAppear:animated];
    sview.frame = CGRectMake(0, 0, 568, 320);
    sview.contentSize = CGSizeMake(4500, 320);
    [sview setScrollEnabled:YES];

}


我认为这应该帮助你。

这篇关于即使设置了内容大小,UIScrollView也不会滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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