你好我有这个疑问可以结束另一个类的刷新控制吗? 在我的tableviewcontroller中我有这个:
func setRefreshGesture() {
let refreshGesture = UIRefreshControl()
refreshGesture.backgroundColor = UIColor.clearColor()
refreshGesture.tintColor = UIColor.whiteColor()
refreshGesture.addTarget(WorkUpdater.sharedInstance,action:#selector(WorkUpdater.attemptUpdateControl),forControlEvents:.ValueChanged)
self.refreshControl = refreshGesture
self.refreshControl?.layer.zPosition = self.tableView.backgroundView!.layer.zPosition + 1
}
在我的另一堂课中......有这个:
func attemptUpdateControl(){
if !isUpdating && canPerformUpdate() {
isUpdating = true
performUpdateControl()
} else {
print("ERROR: - Update in progress")
}
}
func performUpdateControl(){
let reach = Reachability.reachabilityForInternetConnection()!
if reach.isReachable() {
work.getData()
} else {
UIAlertView(title: "Device without connection", message: "You must have an internet connection to use this feature", delegate: nil, cancelButtonTitle: "OK").show()
//这里我想结束我对tableviewcontroller的刷新
}
}
答案 0 :(得分:0)
您可以设置自定义Delegate
或使用NSNotifcationCenter
。我不确定您与TableViewController
的{{1}}关系是什么。
因此,我向您展示了使用WorkUpdater
进行此操作的可能方法。在NSNotifactionCenter
中,请在TableViewController
viewDidLoad
然后有一个NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.refreshCompleted), name:"refreshCompleted", object: nil)
func:
refreshCompleted
同时使用以下内容更新func refreshCompleted() {
refreshGesture.endRefreshing() //you have to set it as a class var
}
:
WorkUpdater