Friday, February 10, 2017

How to User Refresh Controller in pagination Using Swift

No comments :
    var offsetValue: NSInteger!
    var refreshControl: UIRefreshControl!
    @IBOutlet weak var tableView: UITableView!

// MARK: - view life cycle
    
    override func viewDidLoad()
    {
        super.viewDidLoad()
       
        refreshControl = UIRefreshControl()
        refreshControl.addTarget(self, action: #selector(ChatVC.refreshTable(_:)), for: UIControlEvents.valueChanged)
        self.chatTableView.addSubview(refreshControl)
    }
    
    func refreshTable(_:AnyObject)
    {
        offsetValue = offsetValue + 30
//call the web service method  
        self.getMessagesFromSever(offsetValue)
        DispatchQueue.main.async
       {
            self.refreshControl.endRefreshing()
            self.tableView.reloadData()
        }

    }

No comments :

Post a Comment