Skip to content

Instantly share code, notes, and snippets.

@iAmrSalman
Created August 3, 2017 21:59
Show Gist options
  • Save iAmrSalman/91ac5594527c2521ea58c09dff26c545 to your computer and use it in GitHub Desktop.
Save iAmrSalman/91ac5594527c2521ea58c09dff26c545 to your computer and use it in GitHub Desktop.
[tableViewActivityIndicator] Add a ActivityIndicator to the bottom of UITableView while loading #swift3 #tableview #paging
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let lastSectionIndex = tableView.numberOfSections - 1
let lastRowIndex = tableView.numberOfRows(inSection: lastSectionIndex) - 1
if indexPath.section == lastSectionIndex && indexPath.row == lastRowIndex {
// print("this is the last cell")
let spinner = UIActivityIndicatorView(activityIndicatorStyle: .gray)
spinner.startAnimating()
spinner.frame = CGRect(x: CGFloat(0), y: CGFloat(0), width: tableView.bounds.width, height: CGFloat(44))
self.tableView.tableFooterView = spinner
self.tableView.tableFooterView?.isHidden = false
}
}
@parmarhaswini
Copy link

Where to stop it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment