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
-(void)createScroll{
[scroll setScrollEnabled:YES];
[scroll setContentSize:CGSizeMake(320, 1325)];
}
For the paged scroll I have the following where scrollView is the 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? Cheers!
I was creating the scroll view in the viewDidLoadMethod, once I created it in the (void)viewDidAppear:(BOOL)animated method the scroll views worked perfectly.