Created
August 3, 2017 21:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where to stop it ?