当应用程序返回前台时,我遇到重启动画的问题。我检查过这个solution,但它不适合我。
在我的App Delegate中,我在应用程序辞职时取消动画
func applicationWillEnterForeground(application: UIApplication) {
NSNotificationCenter.defaultCenter().postNotificationName("didEnterForeground", object: nil)
}
当应用程序进入前台时,我正在向View Controller发布通知
func playAnimation(notification: AnyObject) {
gameLogic.boardFlash(boardImage)
}
View Controller有一个调用该方法的观察者,但动画没有重新启动。
被叫方法:
boardFlash
func boardFlash(board: UIImageView) {
let options:UIViewAnimationOptions = [.Autoreverse, .Repeat]
UIView.animateWithDuration(0.3, delay: 1.0, options: [options], animations: {
board.alpha = 0.0
}, completion: nil)
}
动画:
{{1}}
我检查过所有内容都被调用,但是动画没有运行。任何帮助将不胜感激。谢谢!
答案 0 :(得分:1)
由于@BlakeLockley评论,我解决了这个问题。
我在观察者方法调用中将Board View alpha设置为1.0。
func playAnimation(notification: AnyObject) {
boardImage.alpha = 1.0
gameLogic.boardFlash(boardImage)
}
现在它运作正常。虽然有趣的解决方案。