相关疑难解决方法(0)

取消dispatch_after()方法?

有没有办法取消未来一段时间内安排的dispatch_after(),到目前为止还没有解雇?我正在尝试为服务器更新调度程序,这个方法就像我想要的那样,但是,我希望在某些时候取消并重新安排它.是否有可能或我必须回退并使用NSTimer?

grand-central-dispatch ios

29
推荐指数
4
解决办法
2万
查看次数

停止dispatch_after

我使用动画来指定提示以帮助延迟交互使用这些:

 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)

但是,如果在动画开始之前,用户触摸屏幕,我需要停止此延迟过程.

animation dispatch swift

15
推荐指数
5
解决办法
1万
查看次数

标签 统计

animation ×1

dispatch ×1

grand-central-dispatch ×1

ios ×1

swift ×1