gpt4 book ai didi

objective-c - 页面控制按钮

转载 作者:行者123 更新时间:2023-11-28 22:56:31 27 4
gpt4 key购买 nike

我正在做一个项目,我需要制作一个包含 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;

最佳答案

您可能正在将页面控件添加到 ScrollView 。您应该将它添加到 ScrollView 的 super View 中,即作为它的兄弟,并在 ScrollView 的顶部。这样它就不会随 ScrollView 一起滚动。

关于objective-c - 页面控制按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10691727/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com