Google News
logo
IOS - Interview Questions
How to add Pull-to-Refresh functionality in an iOS app?
Apple provides us the UIRefreshControl class, which simplifies adding the pull to refresh. The First thing we need to do is instantiate the UIRefreshControl class.
let refreshControl = UIRefreshControl()    
Here, we need to add this refresh control to our view. We can assign the refreshControl property of the view to this instance. However, we must notice that, before iOS 10, there was not a property like refreshControl. We had to add it as a sub view to the view.
if #available(iOS 10.0, *) {    
    tableView.refreshControl = refreshControl    
}     
else {    
    tableView.addSubview(refreshControl)    
}    
Advertisement