zoukankan      html  css  js  c++  java
  • ios 简单的倒计时验证码数秒过程实现

    1. timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];  
    1. //倒计时方法验证码实现倒计时60秒,60秒后按钮变换开始的样子  
    2. -(void)timerFireMethod:(NSTimer *)theTimer {  
    3.     if (seconds == 1) {  
    4.         [theTimer invalidate];  
    5.         seconds = 60;  
    6.         [validCodeBtn_ setTitle:@"获取验证码" forState: UIControlStateNormal];  
    7.         [validCodeBtn_ setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];  
    8.         [validCodeBtn_ setEnabled:YES];  
    9.     }else{  
    10.         seconds--;  
    11.         NSString *title = [NSString stringWithFormat:MSG_DYNAMIC_CODE_WAIT,seconds];  
    12.         [validCodeBtn_ setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];  
    13.         [validCodeBtn_ setEnabled:NO];  
    14.         [validCodeBtn_ setTitle:title forState:UIControlStateNormal];  
    15.     }  
    16. }  
    17. //如果登陆成功,停止验证码的倒数,  
    18. - (void)releaseTImer {  
    19.     if (timer) {  
    20.         if ([timer respondsToSelector:@selector(isValid)]) {  
    21.             if ([timer isValid]) {  
    22.                 [timer invalidate];  
    23.                 seconds = 60;  
    24.             }  
    25.         }  
    26.     }  
    27. }  
  • 相关阅读:
    MVC-READ5(asp.net web from PK asp.net MVC)
    MVC-READ4
    MVC-READ2
    MVC-READ1
    @@ERROR和@@ROWCOUNT的用法
    JS 对输入框文本正在输入中校验
    CSS 父级方法清除浮动方法
    jquery制作滚动条到一定位置触发
    嵌入式app框架
    开发常用软件
  • 原文地址:https://www.cnblogs.com/zhangliukou/p/4124047.html
Copyright © 2011-2022 走看看