I am trying to add a pageviewcontroller on a pre-installed scroll view class that creates a nice effect. Here is how they install the scrollview:
- (void)setTitleArray:(NSArray *)titleArray {
titlesArray = titleArray;
arrayCount = titleArray.count;
self.topTab.frame = CGRectMake(0, 20, FUll_VIEW_WIDTH, PageBtn+20);
self.scrollView.frame = CGRectMake(0, PageBtn+20, FUll_VIEW_WIDTH, FUll_VIEW_HEIGHT - PageBtn - TabbarHeight);
[self addSubview:self.topTab];
[self addSubview:self.scrollView];
}
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.delegate = self;
_scrollView.tag = 318;
_scrollView.backgroundColor = UIColorFromRGB(0xfafafa);
_scrollView.contentSize = CGSizeMake(FUll_VIEW_WIDTH * titlesArray.count, 0);
_scrollView.pagingEnabled = YES;
_scrollView.showsHorizontalScrollIndicator = NO;
_scrollView.alwaysBounceHorizontal = YES;
}
return _scrollView;
}
I created a whole class on pageviewcontroller based on this tutorial: http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/
I then try to implement it in the pre-installed class. For a normal view controller, the it basically add its view onto the scrollview as a subview. I thus revise its method as such:
if (class && viewAlloc[i] == NO) {
if([className containsString:@"VC1"]){
UIPageViewController *ctrl = class.new;
ctrl.view.frame = CGRectMake(FUll_VIEW_WIDTH * i, 0, FUll_VIEW_WIDTH, FUll_CONTENT_HEIGHT - PageBtn);
[pagerView addSubview:ctrl];
viewAlloc[i] = YES;
}
else{
UIViewController *ctrl = class.new;
ctrl.view.frame = CGRectMake(FUll_VIEW_WIDTH * i, 0, FUll_VIEW_WIDTH, FUll_CONTENT_HEIGHT - PageBtn);
[pagerView.scrollView addSubview:ctrl.view];
viewAlloc[i] = YES;
}
}
But the following effect is this, where I can only scroll the horizontal scroll view, but not the page control. I can't even change page by touching the dots. enter image description here