UIScrollView页面负方向

UIScrollView pages in the negative direction

所以我按以下方式设置了一个 UIScrollView,出于某种原因,滚动视图显示如下:

                  Phone Screen

                ---------------
---------------|---------------|
---------------|---------------|
---------------|---------------|
---------------|----Content----|
---------------|---------------|
---------------|---------------|
---------------|---------------|
---------------|---------------|
                ---------------

我的目标是让用户向右滚动,如下所示:

  Phone Screen

 ---------------
|---------------|---------------
|---------------|---------------
|---------------|---------------
|----Content----|---------------
|---------------|---------------
|---------------|---------------
|---------------|---------------
|---------------|---------------
 ---------------

滚动视图的设置方法如下(有点简化,但准确):

CGFrame frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height);
CGSize contentSize = CGSizeMake(self.bounds.size.width*2, self.bounds.size.height);
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame];
scrollView.contentSize = contentSize;
scrollView.propertyN = bool; //E.g. pagingEnabled, bounces, clipsToBounds, etc.

UIImageView *imageView = [[UIImageView alloc] initWithImage:someImage];
imageView.frame = frame;

[scrollView addSubview:imageView];
[self.view addSubview:scrollView];

还有其他人遇到过这个问题吗?我确定我在设置滚动视图时犯了一些非常基本的错误,但似乎无法发现它。

self.view.frameorigin 是否可以在屏幕外(例如 -self.bounds.width)?

我会尝试从简单的代码开始,然后逐步构建您想要的代码。下面是一些类似于上面代码的简单代码,您可以将其放入一个空白项目中,以说服自己您发布的代码不是可能的罪魁祸首:

  CGFloat width = self.view.bounds.size.width;
  CGFloat height = self.view.bounds.size.height;
  CGRect frame = CGRectMake(0.0f,0.0f,width,height);
  CGSize contentSize = CGSizeMake(width*2, height);

  UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:frame];
  scrollView.backgroundColor = [UIColor yellowColor];
  scrollView.contentSize = contentSize;
  scrollView.pagingEnabled = YES;

  UIView *view1 = [[UIView alloc] initWithFrame:frame];
  view1.backgroundColor = [UIColor blueColor];
  UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(width,0.0f,width,height)];
  view2.backgroundColor = [UIColor greenColor];

  [scrollView addSubview:view1];
  [scrollView addSubview:view2];
  [self.view addSubview:scrollView];