想要在tableview底部添加拉動刷新。如何在iOS中快速刷新tableview按鈕swift
首先要在tableview中100的數據顯示,以90
然後添加在拉的實現代碼如下底部刷新。拉它想要顯示80到70,然後拉刷新70到60,然後拉刷新50到40 ...等最終1到10意味着獲取停止顯示「無數據可用」。如何實現這一點。幫助我感謝提前。
在這裏我的代碼。
@IBOutlet weak var dataTbl: UITableView!
var numbers: [Any] = ["90","91","92","93","94","95","96","97","98","99","100"] // display first 100 to 90.
在tableview中加載。
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.numbers.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:UITableViewCell = self.dataTbl.dequeueReusableCell(withIdentifier: cellReuseIdentifier) as UITableViewCell!
cell.textLabel?.text = self.numbers[indexPath.row] as? String
return cell
}
在谷歌搜索添加在tableview的按鈕刷新。我有這個代碼。使用
spinner.startAnimating()
隱藏使用
spinner.stopAnimating()
通過使用此代碼如何
let spinner = UIActivityIndicatorView(activityIndicatorStyle: .gray)
spinner.color = UIColor.darkGray
spinner.hidesWhenStopped = true
tableView.tableFooterView = spinner
顯示微調做拉刷新幫助我。
卻無法實現它。 - 意思是什麼...... –
你想用上面的代碼做什麼? – shahnilay86
你在這裏調用了這個'let spinner = UIActivityIndicatorView(activityIndicatorStyle:.gray) spinner.color = UIColor.darkGray' –