1.先实现按钮点击功能,先写好了按钮,在触发按钮的方法中做如下操作:
-(void)BtnAction:(UIButton *)btn{ //按钮点击
// 在0.2秒时间间隔内多次点击只响应一次点击事件, todoSomething就是我们具体要实现的方法
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(todoSomething:) object:btn]; [self performSelector:@selector(todoSomething:) withObject:btn afterDelay:0.2f]; }
-(void)todoSomething:(UIButton *)btn{
//这里面写timer,timer调自己的方法
}
2.到这里就结束了,关键的就那一步:
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(todoSomething:) object:btn]; [self performSelector:@selector(todoSomething:) withObject:btn afterDelay:0.2f];
希望对大家有所帮助。