105
97

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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()

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

105
97
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
105
97

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?