有没有办法取消未来一段时间内安排的dispatch_after(),到目前为止还没有解雇?我正在尝试为服务器更新调度程序,这个方法就像我想要的那样,但是,我希望在某些时候取消并重新安排它.是否有可能或我必须回退并使用NSTimer?
我使用动画来指定提示以帮助延迟交互使用这些:
let delay = 1.8 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue()) {
//call the method which have the steps after delay.
self.rain.alpha = 0
UIView.animateWithDuration(5, animations: {
self.rain.alpha = 1
})
self.tip.startAnimating()
}
Run Code Online (Sandbox Code Playgroud)
但是,如果在动画开始之前,用户触摸屏幕,我需要停止此延迟过程.