LoginSignup
106
98

More than 1 year has passed since last update.

SwiftでUIRefreshControlを使う

Last updated at Posted at 2014-09-08

SwiftにおけるUIRefreshControlの使い方

UIRefreshCotnrolはTableViewやWebViewを下に引っ張って更新するアレ

viewController.swift
  var refreshControl:UIRefreshControl!

  override func viewDidLoad()
    {
        super.viewDidLoad()

        self.refreshControl = UIRefreshControl()
        self.refreshControl.attributedTitle = NSAttributedString(string: "引っ張って更新")
        self.refreshControl.addTarget(self, action: "refresh", forControlEvents: UIControlEvents.ValueChanged)
        self.tableView.addSubview(refreshControl)
    }

   func refresh()
  {
     // 更新するコード(webView.reload()など)
  }

更新が終了したときに

refreshControl.endRefreshing()

を書いてぐるぐるを終了させる

106
98
6

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
106
98