如何在iOS应用中创建点击器

时间:2014-03-07 14:44:17

标签: ios objective-c

我想创建一种触摸录音机。我有一个带按钮的数组,并且我想要每秒钟点击我的应用程序点击按钮。

for(UIButtons *button in self.tmpRecord) {
        [button sendActionsForControlEvents: UIControlEventTouchUpInside];
        //wait a second
}

我该怎么做?

2 个答案:

答案 0 :(得分:0)

使用NSTimer安排事件每秒重复一次。

这个问题有很多好的答案:How do I use NSTimer?

答案 1 :(得分:0)

您可以使用NSTimer:

NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0f target: self selector: @selector(myMet:) userInfo: nil repeats: YES];



-(void) myMet:(NSTimer*) t 
{
    for(UIButtons *button in self.tmpRecord) {
        [button sendActionsForControlEvents: UIControlEventTouchUpInside];
        //wait a second
    }
}