__block NSInteger timeout= ; //倒计时时间

KWeakSelf

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, );

dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, , ,queue);

dispatch_source_set_timer(_timer,dispatch_walltime(NULL, ),1.0*NSEC_PER_SEC, ); //每秒执行

dispatch_source_set_event_handler(_timer, ^{

if(timeout < ){ //倒计时结束,关闭

dispatch_source_cancel(_timer);

dispatch_async(dispatch_get_main_queue(), ^{

KStrongSelf

//设置界面的按钮显示 根据自己需求设置

self.getCodeBtn.enabled = YES;

[self.getCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];

});

}else{

self.getCodeBtn.enabled = NO;

NSString *strTime = [NSString stringWithFormat:@"%zd秒",timeout];

dispatch_async(dispatch_get_main_queue(), ^{

//设置界面的按钮显示 根据自己需求设置

[self.getCodeBtn setTitle:strTime forState:UIControlStateNormal];

});

timeout--;

}

});

dispatch_resume(_timer);

iOS-登录发送验证码时60秒倒计时,直接用的更多相关文章

  1. button获取验证码60秒倒计时 直接用

    __block ; __block UIButton *verifybutton = _GetverificationBtn; verifybutton.enabled = NO; dispatch_ ...

  2. jQuery实现发送短信验证码后60秒倒计时

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  3. 获取验证码,60秒倒计时js

    <input type="button" id="btn" value="免费获取验证码" /><script type= ...

  4. 微信小程序60秒倒计时

    微信小程序发送短信验证码后60秒倒计时功能,效果图: 完整代码 index.wxml <!--index.wxml--> <view class="container&qu ...

  5. Jquery插件实现点击获取验证码后60秒内禁止重新获取

    通过jquery.cookie.js插件可以快速实现“点击获取验证码后60秒内禁止重新获取(防刷新)”的功能 先到官网(http://plugins.jquery.com/cookie/ )下载coo ...

  6. js实现60秒倒计时效果(使用了jQuery)

    今天碰到要实现一个类似那种短信验证码60秒倒计时的需求,好久不写js,有点手生.把代码记录下,方便后续查阅. 这里我用了jQuey,毕竟写起来简洁点.下面直接看效果和代码. 一.效果          ...

  7. uni验证码60秒倒计时

    其实要实现这个功能原理非常简单,就是setInterval+setTimeout+clearInterval结合使用,首先在data里定义一个变量second,初始值为60,然后在setInterva ...

  8. js jquery 按钮点击后 60秒之后才能点击 60秒倒计时

    var wait = 60; function time(o) { if (wait == 0) { $(o).attr("disabled", false); $(o).val( ...

  9. 点击按钮出现60秒倒计时js代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

随机推荐

  1. jqPaginator分页插件

    如下图效果: 官方地址:http://jqpaginator.keenwon.com/ java后台代码Page对象: /** * * All Rights Reserved. 保留所有权利. */ ...

  2. 【例题收藏】◇例题·6◇ 电压机制(voltage)

    ◆例题·6◆ 电压机制 周六日常模拟赛……已经不知道该说什么了(感觉做不出来的都是好题) ▷ 题目 (终于不用自己翻译英文题了╮(╯-╰)╭) [问题描述] 科学家在“无限神机”(Infinity M ...

  3. IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/app

    web.xml初始化spring容器出错 org.springframework.beans.factory.BeanDefinitionStoreException: IOException par ...

  4. pt-online-schema-change 脚本化

    mysql在线更改表可用工具 pt-online-schema-change 更改,或者用gh-ost更改.pt-online-schema-change 在原表创建索引,跟踪新插入的数据.gh-os ...

  5. 配置Struts2及Struts2访问servlet api的方式

    Struts2的起源与背景 在很长的一段时间内,在所有的MVC框架中,Struts1处于绝对的统治地位,无论是从市场的普及范围,还是具体的使用者数量. 其他MVC框架都无 法与其相比,作为一一款优秀的 ...

  6. github 常用

    1.创建KEY,这个文件生成完了后,要保存好公钥和私钥文件 ssh-keygen -t rsa -C "abc@mail.com" 2.github上添加ssh密钥 3.拷贝公钥信 ...

  7. what is feeding and what is 读扩散 and 写扩散?

    what is feeding? 通俗点说feed系统就是当你登陆进对应网站后:微信朋友圈的动态.人人网上看到的一件件新鲜事.新浪微博上推到你面前的一条条新围脖等等.系统中的每一条消息就是一个feed ...

  8. weui-switch开关控件,表单提交后如何取值

    最近在学习weui这个框架,做了一些小的试验,发现weui-switch控件直接提交不能获取到表单信息,在segmentfault上发现也有人提了这个问题,有人说可以设置一个隐含标签来捕获开关的状态, ...

  9. 【Laravel】查询构造器---使用orWhere的顺序对查询结果产生的不良影响

    实现查询:获取模糊匹配中文名 || 英文名等于 “Sara” 并且 个人信息状态为“待审核” 的员工信息. 其中 $filter = ["eName" => "Sa ...

  10. Bad escape character ‘ygen’ 错误原因!

    ssh-keygen -t rsa -C “邮箱” ssh-keygen 命令中间没有空格,如果在ssh后面加上空格,会得到Bad escape character ‘ygen’.的错误.