繁体   English   中英

如何在发生交互时禁用UICollectionView中的用户交互

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM