UIScrollView + 页面控件

UIScrollView + PageControl

我有一个带有滚动视图出口(初始大小:390、170)和页面控件的视图控制器。我需要它来显示阵列中每页的图像。但是我有意想不到的结果(见下图)。

图片不是全宽的,并且在第二页滚动视图结束后。

这是代码

- (void)viewDidLoad {
    [super viewDidLoad];
    //Put the names of our image files in our array.
    imageArray = [[NSArray alloc] initWithObjects:@"header1.jpg", @"header2.jpg", @"header3.jpg", nil];
    [self.articlesPageControll setNumberOfPages:imageArray.count];
    for (int i = 0; i < [imageArray count]; i++) {
        //We'll create an imageView object in every 'page' of our scrollView.
        CGRect frame;
        frame.origin.x = 390 * i;
        frame.origin.y = 0;
        frame.size = self.articlesScrollView.frame.size;

        UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
        [imageView setContentMode:UIViewContentModeScaleToFill];
        imageView.image = [UIImage imageNamed:[imageArray objectAtIndex:i]];
        [self.articlesScrollView addSubview:imageView];
    }
    //Set the content size of our scrollview according to the total width of our imageView objects.
    self.articlesScrollView.contentSize = CGSizeMake(self.articlesScrollView.frame.size.width * [imageArray count], 170);

}

- (void)scrollViewDidScroll:(UIScrollView *)sender
{
    // Update the page when more than 50% of the previous/next page is visible
    CGFloat pageWidth = self.articlesScrollView.frame.size.width;
    int page = floor((self.articlesScrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    self.articlesPageControll.currentPage = page;
}

UPD:带图片的第 3 页确实存在,但无法滚动到此页

提前致谢!

解决方案self.articlesScrollView.contentSize = CGSizeMake(390 * [imageArray count], 170);