Monday 10 November 2014

Swift + Add Pull to Refresh on Table View


var refreshControl:UIRefreshControl!      // An optional variable




func viewDidLoad()
{
        super.viewDidLoad()

        self.refreshControl = UIRefreshControl()
        self.refreshControl.attributedTitle = NSAttributedString(string: "Pull to refersh")
        self.refreshControl.addTarget(self, action: "refresh:", forControlEvents:                 
        UIControlEvents.ValueChanged)
        self.tableView.addSubview(refreshControl)
 }

   func refresh(sender:AnyObject)
  {
     // Code to refresh table view  
  }




At some point you could end refreshing.
self.refreshControl.endRefreshing()

No comments:

Post a Comment