我已经在我的 View Controller 中实现了 scrollViewDidScroll: 以在我上下 ScrollView 时产生一些动画。
但是,当我在 viewcontroller 中滚动我的 collectionview(水平)时,它弄乱了我在 scrollViewDidScroll 中的动画:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
newAlpha = 1 - scrollView.contentOffset.y / 200;
self.introImageView.alpha = newAlpha;
//... -> prevent scrolling when collectionview is scrolled
}
当水平滚动我的 collectionview 时,如何防止调用 scrollViewDidScroll:?
最佳答案
最好的方法不是禁用委托(delegate)方法,而是确保仅在 ScrollView 调用时调用该代码。这是一个例子
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.myScrollView) {
newAlpha = 1 - scrollView.contentOffset.y / 200;
self.introImageView.alpha = newAlpha;
} else {
//collectionView would fall here
}
}
关于ios - 禁用 scrollViewDidScroll : when scrolling UICollectionView - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52542186/