[英]Adding a paged ui scroll view on top of another ui scroll view
I'm have a vertical scroll and I want to add a paged scroll view on top of it to go through a set of pictures. 我有一个垂直滚动,我想在其顶部添加一个分页滚动视图以浏览一组图片。 I have both of scroll views set up through the interface builder.
我已经通过界面构建器设置了两个滚动视图。 For the vertical scroll I have the following where scroll is the UIScrollView
对于垂直滚动,我有以下内容,其中scroll是UIScrollView
-(void)createScroll{
[scroll setScrollEnabled:YES];
[scroll setContentSize:CGSizeMake(320, 1325)];
}
For the paged scroll I have the following where scrollView is the UIScrollView 对于页面滚动,我具有以下内容,其中scrollView是UIScrollView
for (int i = 0; i < array.count; i++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIView *subview = [[UIView alloc] initWithFrame:frame];
subview.backgroundColor = [array objectAtIndex:i];
[self.scrollView addSubview:subview];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * array.count, self.scrollView.frame.size.height);
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = array.count;
The problem is that the images are not showing up in the paged scroll view. 问题是图像没有显示在页面滚动视图中。 I put the paged scroll into a single view test app and it works fine, however it doesn't work when I add it on top of the vertical scroll.
我将分页的滚动条放入单个视图测试应用程序中,并且工作正常,但是当我将其添加到垂直滚动条的顶部时,该滚动条将不起作用。 I have a feeling that it has something to do with adding it to the subview, but I'm new to obj-c and not sure what order the subviews should go in. Anybody have any advice?
我感觉这与将其添加到子视图中有关,但是我是obj-c的新手,不确定该子视图应以什么顺序进入。有人有什么建议吗? Cheers!
干杯!
我是在viewDidLoadMethod中创建滚动视图的,一旦在(void)viewDidAppear:(BOOL)动画方法中创建了滚动视图,滚动视图就可以完美地工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.