LoginSignup
28
27

More than 5 years have passed since last update.

UICollectionViewで、下に引っ張ったときにぐるぐる更新させる方法

Last updated at Posted at 2015-03-06
@IBOutlet weak var myCollectionView: UICollectionView!

override func viewDidLoad() {
        super.viewDidLoad()

        //UIRefreshControllのインスタンスを生成する。
        var refreshControl = UIRefreshControl()
        //下に引っ張った時に、リフレッシュさせる関数を実行する。”:”を忘れがちなので注意。
        refreshControl.addTarget(self, action: "guruguru:", forControlEvents: UIControlEvents.ValueChanged)
        //UICollectionView上に、ロード中...を表示するための新しいビューを作る
        myCollectionView.addSubview(refreshControl)
    }

        //リフレッシュさせる
    func guruguru(sender:AnyObject) {
        sender.beginRefreshing()
        myCollectionView.reloadData()
        sender.endRefreshing()
    }
28
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
27