【问题标题】:UIButton moving and touchUIButton 移动和触摸
【发布时间】:2013-02-07 07:40:25
【问题描述】:

我已经阅读了几个关于移动 UIButton 的主题,并且可以在移动时触摸按钮。现在我正在使用 UIView beginAnimation,但按钮在移动时无法触摸。

我也读过一些关于 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];

【问题讨论】:

    标签: cocoa-touch uibutton touch


    【解决方案1】:

    有可能在按钮动画时,您的主线程被锁定,这使得它无法处理界面交互。按钮动画时可以按其他东西吗?

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

    【讨论】:

    • 是的,我可以触摸其他不动的按钮
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    • 2014-12-18
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 1970-01-01
    相关资源
    最近更新 更多