刷新进度条只会到达95%,只有当你从屏幕顶部滑动到底部时,刷新才会生效。
lazy var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action:
#selector(VFeedVC.refresh(_:)),
for: .valueChanged)
return refreshControl
}()
override func viewDidLoad() {
self.tableView.addSubview(refreshControl)
}
func refresh(_ sender: Any) {
Metric.sendEvent("RefreshFeed")
self.refreshControl.beginRefreshing()
self.getFeeds(self.user.id)
}
func getFeeds(_ userId: Int) {
VNetwork.getFeeds(userId) { feeds in
self.feeds = feeds
self.tableView.isHidden = self.feeds.count == 0
self.configureCells()
self.refreshControl.endRefreshing()
self.tableView.reloadData()
}
}