页面控制按钮

时间:2012-05-21 19:55:42

标签: objective-c ios cocoa-touch uiscrollview uipagecontrol

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

[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;

1 个答案:

答案 0 :(得分:2)

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