mercredi 24 juin 2015

UIRefreshControl methods do nothing in Swift

I am giving my first steps with Swift, and in this case I am trying to implement a UITableViewController. I have subclassed the table view controller and 'Enabled' its Refreshing parameter in IB.

My problem is that calling beginRefreshing or endRefreshing do absolutely nothing to the refresh control. I have been using refresh controls successfully in ObjC, so there must be something I still don't get right in my implementation. Below is my code for the subclass of the table view controller:

import UIKit

class ConcertsViewController: UITableViewController {
    @IBOutlet var concertsTable: UITableView!
    var concerts: [ConcertModel]?

    override func viewDidLoad() {
        super.viewDidLoad()

        //configures refresh control
        self.refreshControl?.addTarget(self, action: "refreshTable:", forControlEvents: UIControlEvents.ValueChanged)
        self.refreshControl?.beginRefreshing()
        getAllConcerts()
    }

    private func getAllConcerts(){

        ConcertModel.getAllConcerts { (concerts, response, error) -> Void in
            self.concerts = concerts
        }
    }

    func refreshTable(refreshControl: UIRefreshControl){
        refreshControl.endRefreshing()
    }

}

See more ..

Aucun commentaire:

Enregistrer un commentaire