【发布时间】:2019-11-23 16:16:09
【问题描述】:
应用程序选项卡使用刷新按钮来更新列表,效果很好。尝试使用“下拉刷新”但根本不起作用。
protocol StaffHistoryDelegate: class {
func updateList()
}
class StaffHistoryController: UIViewController {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var activityLoad: UIActivityIndicatorView!
let myRefreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.attributedTitle = NSAttributedString(string: " ")
refreshControl.addTarget(self, action: #selector(refresh(sender:)), for: .valueChanged)
return refreshControl
}()
override func viewDidLoad() {
super.viewDidLoad()
prepareSearch()
delegateStaffHystory = self
do { try self.frc.performFetch() }
catch {}
tableView.refreshControl = myRefreshControl
}
@IBAction func btnRefreshPressed(_ sender: UIBarButtonItem) {
loadingShow(text: " ")
delegateTabController?.loadStaffBill(completion: { (error) in
DispatchQueue.main.async {
loadingHide()
if error != nil {
let alert = getAlert(title: error?.localizedDescription, message: nil)
self.present(alert, animated: true, completion: nil)
}
}
})
}
@objc private func refresh(sender: UIRefreshControl) {
updateList()
tableView.reloadData()
sender.endRefreshing()
}
很遗憾,我不是编码员,我真的很难理解该做什么。 (我设法在其他 2 个选项卡上实现了“下拉刷新”,但这个选项卡的编码方式不同)。
【问题讨论】:
标签: ios swift xcode uirefreshcontrol