I have a tableview, where I get sometimes 1000 or 40 or sometime even 4 values, but I want that when I got more than 100 values I want to display my array in a 10 - 10 scrolling.
Scrolling the tableview up, I need a scrolling pause after 10 rows are scrolled up, with this code it is giving errors, My array is in [Any] and want to scrolling like Facebook and instagram
I want to get my array into 10 rows first and then I can append the next 10.
var allUserArray = [Any]()
override func viewDidLoad() {
super.viewDidLoad()
var index = allUserArray.first
while index < limit {
allUserArray.append(index)
index = index + "1"
}
}
extension AdvanceSearchViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return allUserArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "advanceSearch") as! AdvanceSearchTableViewCell
let userData = allUserArray[indexPath.row] as! [String: Any]
let dob = userData["dob"] as! String
let age = self.getAgeFromDate(dob: dob)
let photo1 = userData["photo1"] as? String
let height = userData["Height"] as? String ?? "null"
let religion = userData["Religion"] as? String ?? "null"
cell.userNameLabel.text = "HM- \(userData["ProfileID"] as! String)"
cell.userProfessionLabel.text = userData["Profession"] as? String ?? "null"
cell.userAgeLabel.text = "\(age), \(height), \(religion)"
if let profileImage = photo1 {
urlStringOne = "\(USER_IMAGE_BASE_URL)\(profileImage)"
} else {
if (UserDefaults.standard.value(forKey: "gender") as! String == "Female") {
urlStringOne = "\(USER_IMAGE_URL_MALE)"
} else {
urlStringOne = "\(USER_IMAGE_URL_FEMALE)"
}
}
loadImage(urlStringOne, cell)
return cell
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if self.allUserArray.count != nil {
self.totalEnteries = self.allUserArray.count
print("idealist/\(self.allUserArray.count)")
print("total123/\(self.totalEnteries)")
var entries = allUserArray.count - 1
print("total-00/\(entries)")
If indexPath.row == entries {
print("(----------)")
if allUserArray.count < totalEnteries {
var index = allUserArray.count as! String
self.limit = index + "20"
while index < self.limit {
self.allUserArray.append(index)
index = index + "1"
}
self.perform(#selector(self.loadTable), with: nil, afterDelay: 2.0)
}
}
}
}
@objc func loadTable() {
self.advanceSearchTableView.reloadData()
}
}