[英]Make a UI scroll view scroll with a UIPageViewController
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. 我正在创建一个应用程序,我试图让一个pagescrollviewcontroller滑动屏幕,并让顶部的“导航”栏标题滚动实时与标题我有标题栏视图作为自定义视图,我能够访问滚动委托自定义滚动视图和网页浏览控制器的方法。 However.
然而。 I don't see how to access the real time scroll pos?
我没看到如何访问实时滚动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.
我知道这是可能的,因为twitter做到了(真的不应该在任何人的词汇中),但我不知道如何实现这一目标。
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];
}
You'll find the real time position in scrollViewDidScroll
: 您将在
scrollViewDidScroll
找到实时位置:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
// X scroll
//
CGFloat percentage = scrollView.contentOffset.x / scrollView.contentSize.width;
NSLog(@"Scrolled percentage: %f", percentage);
}
Hope that helps! 希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.