SpringIndicator
SpringIndicator copied to clipboard
Preventing second refresh
I am trying to prevent second refresh before finishing the first one.
override func viewDidLoad() {
super.viewDidLoad()
refreshController.indicator.lineColor = UIColor.selectedOrange()
refreshController.addTarget(self, action: "onRefresh", forControlEvents: .ValueChanged)
tableView.addSubview(refreshController)
}
func onRefresh() {
if refreshController.refreshing {
print("Returning")
return
}
// do the refresh
}
Hi, @tosbaha
refreshing was something issue?
My problem is I can't stop second refreshing from onRefresh
For example
func onRefresh() {
print("Refreshing \(refreshController.refreshing)")
if refreshController.refreshing {
return
}
let delay = 1.0 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue()) {
self.refreshList(){ error in //some lengthy task
self.refreshController.endRefreshing()
}
}
}
I don't know why but it does just keep spinning. I was expecting to see 1 refresh which will call my refreshList method then when it does it will call self.refreshController.endRefreshing()
However if I change the condition to
if !refreshController.refreshing {
return
}
It works. I really didn't get it.