美文网首页
button防止重复点击

button防止重复点击

作者: iOS攻城狮_Runloop | 来源:发表于2018-07-03 18:37 被阅读0次

对于与服务器有交互的点击事件:点击的时候判断bool值;在发送请求前设置一次;服务器得到应答后改变bool值即可`

ios开发之单位时间内限制button的点击次数

-(void)btnClick:(UIButton *)btn{
if (btn.selected) return;
btn.selected = YES;
[self performSelector:@selector(timeEnough:) withObject:nil afterDelay:3.0];
//你要实现的button点击事件
 
}
-(void)timeEnough:(UIButton *)btn{
btn.selected = NO;
}

这样的效果就是该button在3秒内只能触发一次点击事件,防止button点击频率过快.

相关文章

网友评论

      本文标题:button防止重复点击

      本文链接:https://www.haomeiwen.com/subject/lyujuftx.html