[英]how to disable user interaction in a UICollectionView while an interaction is occurring
我試圖在contentOffset小於或等於零時禁用UICollectionView中的滾動。 當滾動發生時。
碼:
extension MyController: UIScrollViewDelegate {
func scrollViewDidScroll(scrollView: UIScrollView) {
print("scrollView.contentOffset: \(scrollView.contentOffset)")
if scrollView.contentOffset.y <= 0 {
scrollView.userInteractionEnabled = false
} else {
scrollView.userInteractionEnabled = true
}
}
}
這僅在用戶停止滾動時才禁用交互。
滾動發生時如何禁用交互?
謝謝
我不認為您可以那樣做。
您應該查看UIScrollViewDelegate: https : //developer.apple.com/library/prerelease/ios//documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIScrollViewDelegate並嘗試設置當用戶嘗試滾動太遠時,collectionview的contentOffset會返回0。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.