【发布时间】:2015-03-29 10:11:51
【问题描述】:
我正在使用xcode,但在自动移动按钮时遇到问题。我有这个函数,每当我调用它时,我希望按钮移动到我设置的坐标:
[movebutton setCenter:CGPointMake(164,50)];
之前我尝试在 IBAction 函数中设置 NStimer,然后使用计时器调用此 movebutton 函数 - 按钮已移动,但如果我在没有 NStimer 的情况下调用相同的函数,它将不再有效.
定时器的代码是:
[NSTimer scheduledTimerWithTimeInterval:(0.1/3) target:self selector:@selector(movebutton:) userInfo:nil repeats:YES];
谁能发现我错过了什么?
更新:
我尝试打印出按钮的 x 和 y 坐标,实际上按钮位置已更新。
NSLog(@"x position %f",movebutton.frame.origin.x);
然而,在 UI 屏幕上它根本不反映。
【问题讨论】:
标签: objective-c xcode uibutton