Sometimes when we are writing forum for an App, we may face with that when want the user to pull down the tableView and then, it can refresh the UITableView automatically to present the latest posts. Luckily, there is a very convenient way to do it.:-)
Firstly, we need to define a UIRefreshControl, like:
Then, add a target for that control by:
|
|
The tintColor
is for change the color of the activity indicator. Then function refresh
is what we need to implement when the user scroll down the tableView, here is an example:
It is very important to add refreshControl.endRefreshing()
, because, when the implementation is finished, the activity indicator should disappear.