UIRefreshControl on UICollectionView only works if the collection fills the height of the container

前端 未结 7 1307
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 05:35

I\'m trying to add a UIRefreshControl to a UICollectionView, but the problem is that the refresh control does not appear unless the collection view

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 06:02

    Larry's answer in swift:

        let refreshControl = UIRefreshControl()
        refreshControl.tintColor = UIColor.blueColor()
        refreshControl.addTarget(self, action: "refresh", forControlEvents: .ValueChanged)
        collectionView.addSubview(refreshControl)
        collectionView.alwaysBounceVertical = true
    

    Swift 3:

        let refreshControl = UIRefreshControl()
        refreshControl.tintColor = .blue
        refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
        collectionView.addSubview(refreshControl)
        collectionView.alwaysBounceVertical = true
    

提交回复
热议问题