1
我有一个scrollView
,而在scrollview
里面包含一个collectionView
。带有UICollectionView子项的UIScrollView
只需一次滑动,我想滚动外部scrollView
,直到内部scrollView
进入框架,然后停止外部滚动并滚动内部(所有这些都在一次滑动中)。 所以基本上我想通过从外部到内部的即时滚动。
我能够达到这样的效果,但是我必须删除我的手指,然后再次按我的手指向下滚动另一种观点认为:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//general scroll info
CGFloat scrollOffset = scrollView.contentOffset.y;
//if the scrollview reaches the top then pass the touch to my collection view
//however i must remove my finger and press again in order to scroll the collectionview
if (scrollView == _scrollView && scrollOffset >= 120){
[_scrollView setScrollEnabled:NO];
[_scrollView setBounces:NO];
[_collectionView setScrollEnabled:YES];
[_collectionView setBounces:YES];
[self.scrollView setContentOffset:CGPointMake(0, 120) animated:YES];
}else if (scrollView != _scrollView && scrollOffset < 0){
[_scrollView setScrollEnabled:YES];
[_scrollView setBounces:YES];
[_collectionView setScrollEnabled:NO];
[_collectionView setBounces:NO];
[self.collectionView setContentOffset:CGPointMake(0, 0) animated:YES];
}
}
我希望能够做到这一点,而不必移开我的手指。
有什么想法?
UICollectionView是一个滚动视图本身,为什么你需要外滚动视图的所有这些麻烦? – Andy 2014-12-06 01:42:35
它是我想要达到的效果所必需的。 我想放置一个图像上方的collectionView,然后我scrollView上方的imageview和一旦它的imageView完全覆盖,collectionView应该开始滚动 – 2014-12-06 01:49:51