Make a UI scroll view scroll with a UIPageViewController
ios, objective-c, uipageviewcontroller, uiscrollview
Solution
You'll find the real time position in `scrollViewDidScroll`:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// X scroll
//
CGFloat percentage = scrollView.contentOffset.x / scrollView.contentSize.width;
NSLog(@"Scrolled percentage: %f", percentage);
}
Hope that helps!
Problem
I am creating an app where I am trying to have a pagescrollviewcontroller swipe through screens and have the top "nav" bar titles scroll real time with the titles i have the title bar view as a custom view and I am able to access the scroll delegate methods for both the custom scroll view and the pageview controller. However. I don't see how to access the real time scroll pos? I know it is possible because twitter does it (really can't shouldn't be in anyone's vocabulary) but I am not sure how to achieve this. a picture the home title swipes at the same scroll pos as the pagecontrollers. current code: ``` - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { if(scrollView.tag == 100) { CGPoint point = CGPointMake(mainScrollView.contentOffset.x * 1,0); [titleSwipe setContentOffset:point animated:YES]; } else { mainScrollView.contentOffset = CGPointMake(0,1); [mainScrollView setContentOffset:titleSwipe.contentOffset animated:YES]; } } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate: (BOOL)decelerate { CGPoint point = CGPointMake(mainScrollView.contentOffset.x * 2,0); [titleSwipe setContentOffset:point animated:YES]; } ```