0

我正在做一个项目,我需要用 3 个图像制作一个 PageControl。它正在工作,但页面控件的图像,三个小圆圈只出现在第一张图像上。我做错了什么?

[scrollView setScrollEnabled:YES];

CGRect frame;
frame.size = self.scrollView.frame.size;


//INICIO SCROLLVIEW DE FOTOS

//Fotos ---------
NSArray *imagens = [NSArray arrayWithObjects:@"foto1.png",@"foto1.png",@"foto1.png", nil];
//Fotos ---------

for (int i = 0; i < imagens.count; i++) {
    CGRect frame;

    frame.origin.x = self.listaFotos.frame.size.width * i;
    frame.origin.y = 0;
    frame.size = self.listaFotos.frame.size;

    //Imagem
    frame.origin.y = 0;
    frame.size = CGSizeMake(491, 330);

    UIImage *image = [UIImage imageNamed:[imagens objectAtIndex:i]];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = frame;

    [self.listaFotos addSubview:imageView];

    frame.origin.x = self.listaFotos.frame.size.width * i;

}

self.listaFotos.contentSize = CGSizeMake(self.listaFotos.frame.size.width * imagens.count, self.listaFotos.frame.size.height);

self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = imagens.count;
4

1 回答 1

2

您可能正在将页面控件添加到滚动视图。您应该将它添加到滚动视图的超级视图,即作为它的兄弟,并在滚动视图的顶部。这样它就不会随着滚动视图滚动。

于 2012-05-21T19:58:19.260 回答