2010-10-12 139 views
0

我读过几个主题来移动一个UIButton,并可以触摸按钮时,它的移动。现在我正在使用UIView beginAnimation,但当它移动时,按钮不能被触摸。UIButton移动和触摸

我也读过一些关于NSTimer的内容,但这不是在我的项目中做的最好方法。

有没有别的办法,有人有同样的问题?


这里我举的例子代码..

UIButton *buttonTapObject = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
[buttonTapObject addTarget:self action:@selector(tapObjectTapped:) forControlEvents:UIControlEventTouchUpInside]; 
buttonTapObject.tag = 100; 
buttonTapObject.frame = CGRectMake(-80.0, 40.0, 80.0, 80.0); 

[UIView beginAnimations:@"example" context:NULL]; 
[UIView setAnimationDuration:2.0]; 

// Move to right 

buttonTapObject.center = CGPointMake(360.0, 100.0); 

[UIView commitAnimations]; 

回答

0

有机会的话,虽然钮的动画,你的主线程被锁定,这使得它所以没有界面的交互都可以加工。你可以按下其他的东西,而按钮是动画?

如果没有,请将您的动画移至后台线程。

+0

是的,我可以触摸其他按钮,不会移动 – Flappy 2010-10-12 14:05:42

+0

后处理动画的一些代码。 – DexterW 2010-10-12 15:30:32