我有以下小功能,其中包含我想要执行的两个主要操作。三秒钟的动画,然后在该动画完成后,另一个函数调用。然而,正在发生的是调用另一个函数的代码行在 UIView 动画完成之前正在执行。
func switchToNormalState() {
print("Switching to Normal State")
currentState = "normal"
intervalCounter = intervalCounter + 1
setVisualsForState()
UIView.animateWithDuration(Double(normalDuration), animations: { () -> Void in
self.ProgressBar.setProgress(1.0, animated: true)
}, completion: { _ in
self.switchToFastState()
})
}
我研究了其他类似的帖子以寻找解决方案,但没有一个解决方案解决了我的难题。为了使这些动作成为顺序而不是同时发生,我在完成块中做错了什么?