zoukankan      html  css  js  c++  java
  • iOS定时器按钮短时间内多次点击只触发一次事件方法

    今天在看别人代码的时候,有个个60秒获取验证码的功能,做了个定时器,按钮触发定时器,点击按钮后设置按钮的enabled为NO,逻辑来讲都是没问题的

    但是实际操作的时候,恶意的在短时间内多次点击那个获取验证码按钮,按钮的点击事件被调用了多次,定时器从而也调用多次,本来一秒减一的事件变成了一秒减多,并且减到0后继续调用方法,直到响应点击次数调用完,于是自己进行了下纠正:

    按钮点击触发的方法:

    在0.2秒时间间隔内多次点击只响应一次点击事件。

    - (void)clickSecdCodeButton:(UIButton *)button{
        NSLog(@"send code");
        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(handleSendSmsResult) object:button];
        [self performSelector:@selector(handleSendSmsResult) withObject:button afterDelay:0.2f];
        [_selectTextField resignFirstResponder];
    //    [self requestIdentifyCode:@"" parameters:[@{@"mobilePhoneNumber":self.phoneNumberTextField.text,@"countryCode":@"+86"} mutableCopy]];
    }
  • 相关阅读:
    用例失败重新运行
    pytest启动浏览器,失败用例截图
    解决pycharm问题:module 'pip' has no attribute 'main'
    pytest的HTML
    pytest 的 yield
    pytest的setup和teardown
    pytest的fixture和conftest
    pycharm运行pytest
    简单易用的MongoDB
    快速入门系列--CLR--02多线程
  • 原文地址:https://www.cnblogs.com/pengsi/p/8136229.html
Copyright © 2011-2022 走看看