簡體   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