Swift - disable refreshControl while searching
While searching, I want to disable the pull mechanism for the update. So I turned off update management and uninstalled it. But when pulling down to refresh, the beginRefresh method is called and the cells stay for 2 seconds as there is refresh.
func searchBarShouldBeginEditing(searchBar: UISearchBar) -> Bool {
resultSearchController.searchBar.selectedScopeButtonIndex = 0
refreshControl!.enabled = false
refreshControl?.removeFromSuperview()
return true
}
+3
source to share
2 answers
Use these two functions when you want to create or remove update controls at the top of the UITableView.
func createRefreshControl() {
// Create RefreshControl and add to tableView
self.refreshControl = UIRefreshControl()
self.refreshControl!.attributedTitle = NSAttributedString(string: " ↓ Refresh ↓ ")
self.refreshControl!.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
}
func deleteRefreshControl() {
// delete RefreshControl
self.refreshControl = nil
}
+2
source to share