user970956
user970956

Reputation: 339

change position of UIRefreshControll and trigger even

I'm trying to make a table view which display a list of cars. For the first time it returns 20 records from server and I want new data to be loaded if the user scroll to the end of table and when it get close to the end of the rows then new data loaded with displaying a snipper like instagram or facebook apps. For that I tried UIRefreshControll and here are my codes

refreshControl = UIRefreshControl()
refreshControl?.backgroundColor = UIColor.whiteColor()
refreshControl?.tintColor = UIColor.grayColor()
refreshControl?.addTarget(self, action: "getRecords", forControlEvents:UIControlEvents.ValueChanged)

the problem with that code is that It only trigger the action at top of the table view .How should this code be modified to trigger the action when the user close to the end of rows of table view and change the position of spinner from top to bottom ?

Thanks

Upvotes: 0

Views: 116

Answers (1)

Nikos M.
Nikos M.

Reputation: 13783

Add a cell with just a spinner in it at the bottom of your table. Return +1 rows (so you have all your data plus a row with the loading cell). In this loading cell add an action so it refreshes the table:

func reloadTheTable(){
 self.tableView.reloadData()
}

Upvotes: 1

Related Questions