本文介绍了UIDynamicAnimator - 不会UIView的工作,但将与Self.View?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用苹果的示例应用程序这个code和它调整到我的。我想要的UIImageView gameOverFalling 运行此方法(反弹的下跌及实物为准)。它应该与UIView的 finalScoreView 碰撞,你可以在网上看到2

   - (无效){gameOverFallingMethod
    UIDynamicAnimator *动画= [[UIDynamicAnimator页头​​] initWithReferenceView:finalScoreView];    UIGravityBehavior * gravityBeahvior = [[UIGravityBehavior页头] initWithItems:@ self.gameOverFalling]];
    [动画addBehavior给:gravityBeahvior];    UICollisionBehavior * collisionBehavior = [[UICollisionBehavior页头] initWithItems:@ self.gameOverFalling]];
    //苹果说:从创建动态动画的的边界碰撞边界
    //引用视图(self.view)。
    collisionBehavior.translatesReferenceBoundsIntoBoundary = YES;
    collisionBehavior.collisionDelegate =自我;
    [动画addBehavior给:collisionBehavior];    self.animator =动画师;
}

然而,当我跑我的应用程序,它返回一个线程1:SIGABRT错误。在控制台:

It works when I replace 'finalScoreView' on line 2 with 'self.view', but then it falls to the bottom of the whole screen.

Any ideas what I did wrong? I would love to know, thanks!

解决方案

It appears from the exception that self.gameOverFalling does not descend from finalScoreView in your view hierarchy. See the quote from UIDynamicAnimator class reference:

这篇关于UIDynamicAnimator - 不会UIView的工作,但将与Self.View?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:42