2016-07-07 1 views
1

UICollectionView을 스크롤하려면 scrollToItemAtIndexPath:atScrollPosition:animated을 사용합니다. 이 자동 스크롤이 진행되는 동안 일부 기능을 사용 중지 한 다음 스크롤이 끝나면 다시 사용하도록 설정해야합니다. 이미 볼 수있는 일부 셀로 스크롤하려고 할 때 문제가 발생합니다. 스크롤이 필요하지 않습니다 (예 : 마지막 셀 및 콜렉션 뷰가 맨 끝까지 이미 스크롤 됨). 이 경우 scrollViewDidEndDragging이나 scrollViewDidEndDecelerating이 호출됩니다.scrollToItemAtIndexPath :가 호출 된 후 UICollectionView가 실제로 스크롤되는지 여부를 확인하는 방법?

scrollToItemAtIndexPath이 실제로 UICollectionView으로 스크롤되는지를 알 수있는 방법이 있습니까?

답변

0

& scrollview scrolls & 중요한 변경 후에 만 ​​스크롤 적용 할 때마다 최신 스크롤 뷰 오프셋 & 변경 사항을 저장할 수 있다고 생각합니다.

 func scrollViewDidScroll(scrollView: UIScrollView) { 

      let scrollOffset = scrollView.contentOffset.y; 

      if scrollOffset < (previousValue-100) || scrollOffset > (previousValue+100) 
       { 
       // Scrolled up or down with 100 points which you can change 
       previousValue = scrollOffset 
       } 
    } 
+0

나는'scrollViewDidEndDragging'을 사용할 수 있습니다. 그러나 스크롤이 시작되지 않았을 때 어떻게해야합니까? 나는 그것을 알아야한다. – Jaroslav

+0

유용 할 수 있음을 확인하십시오. http://stackoverflow.com/questions/18649920/uicollectionview-current-visible-cell-index –

0

당신은 scrollToItemAtIndexPathscrollToItemAtIndexPath를 호출하기 전에 셀의 프레임을 기반으로 스크롤할지 여부를 결정할 수 있습니다. 그냥 원하는 경우 예를 들어, 셀 (UICollectionViewScrollPositionNone) 볼 수 있도록 : 그것은 scrollToItemAtIndexPath은 단순히 스크롤 여부를 알려하지 않는 불행한

UICollectionViewLayoutAttributes* attrs = [collectionView layoutAttributesForItemAtIndexPath:indexPath]; 
CGRect frame = [collectionView convertRect:attrs.frame toView:self.view]; 
BOOL willScroll = !CGRectContainsRect(collectionView.frame, frame); 

.

관련 문제