I want to implement a UIPushBehavior in Swift, but I 'm always getting following error: ... View item UIImageView should be a descendant of reference view in UIDynamicAnimator ...
I 'm adding the view to the behavior and the behavior to the animator...
@IBAction func push(sender: UITapGestureRecognizer) {
let pushBehavior = UIPushBehavior(items: [aView], mode: .Instantaneous)
pushBehavior.magnitude = 0.5
pushBehavior.action = { [unowned pushBehavior] in
pushBehavior.dynamicAnimator!.removeBehavior(pushBehavior)
}
animator.addBehavior(pushBehavior)
}
I also set the referenceView of the animator to the gameView where the action should happen...
private lazy var animator : UIDynamicAnimator = {
let lazilyCreatedDynamicAnimator = UIDynamicAnimator(referenceView:self.gameView)
return lazilyCreatedDynamicAnimator
}()
I hope you can help me figuring out what to do to solve my little problem...