2016-09-25 10 views
1

オンラインでいくつかの例を実行したところ、MKAnnotationViewをアニメーション化しようとしています。私は私のMKAnnotationViewサブクラスの()のinitに次のコードを配置した:とすぐに注釈ビューをマップに追加されているようMKAnnotationViewをアニメーション化しようとするとアプリケーションがクラッシュする

UIView.animate(withDuration: 10.0, delay: 0.0, options: .repeat, animations: {    
    UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.5, animations: { 
     self.frame = biggerFrame 
    }) 

    UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.5, animations: { 
     self.frame = originalFrame 
     }) 
}, completion: nil) 

、以下の例外を除いて、アプリがクラッシュ:

2016-09-25 19:32:58.655 MyApp 42[62332:4524529] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[UIView addKeyframeWithStartTime:duration:animations:] must be called inside the animations block of +[UIView animateKeyframesWithDuration:delay:options:animations:completion:]' 

私が間違っていることは何ですか?

ありがとうございます!

答えて

1

コンソールが示唆したように、あなたが使用する必要があります。

代わり
UIView.animateKeyframes(withDuration: TimeInterval, delay: TimeInterval, options: UIViewKeyframeAnimationOptions, animations: { 
    your animation here 
    }, completion: nil) 

:)

現在、あなたはUIViewのを使用しています。 アニメーション(withDuration:遅延:オプション:アニメーション:完了:)

+0

D'oh!私は将来、エラーメッセージを少し慎重に読むべきだと思う。 –

関連する問題