【发布时间】:2011-11-10 04:13:53
【问题描述】:
我正在使用UIView 动画在屏幕上移动按钮。当它移动时,我有一个 NSTimer 运行该方法
checkForCollision
看起来像这样:
for(UIButton* b in squares)
if(CGRectIntersectsRect(playerSquare.frame, b.frame)) {
[self showEndMenu];
break;
}
间隔为 0.05;我希望该方法在按钮移动到另一个路径时通知我。问题似乎在于,当它检查 UIButton b 的框架时,它只看到按钮正在移动的框架。
我有这样的动画按钮:
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationDuration:1.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
view.center = destPoint;
[UIView commitAnimations];
因此,如果 destPoint 与 CGRect playerSquare.frame 相交,则调用 [self showEndMenu]。但是,如果按钮所在的帧/位置,比如说,动画的一半,与playerSquare 相交,[self showEndMenu] 就不会被调用。我不知道如何解决这个问题;如果需要,我可以提供更多代码。谢谢!
【问题讨论】:
标签: ios uibutton uianimation quartz-core