【iOS学步】点击获取验证码倒计时功能

先记一下踩的弱智坑:
倒计时事件中,计时结束,按钮的状态应设置为 UIControlStateNormal,竟然错写成了 UIControlStateDisable,还调试了半天,只能说无地自容了。

- (void)secondChangeAction {
    NSLog(@"倒计时开始");
    if (self.secondsCount > 0) {
        _getCaptchaBtn.layer.borderColor = [UIColor colorWithHexString:@"979797"].CGColor;
        self.getCaptchaBtn.enabled = NO;
        [self.getCaptchaBtn setTitle:[NSString stringWithFormat:@"%lds",self.secondsCount] forState:UIControlStateNormal];
        self.secondsCount--;
    }
    else {
        _getCaptchaBtn.layer.borderColor = kAppBaseGreenColor.CGColor;
        self.getCaptchaBtn.enabled = YES;
        [_getCaptchaBtn setTitle:[NSString stringWithFormat:@"重新获取验证码"] forState:UIControlStateNormal]; //错写为Disable了
        self.secondsCount = 0;
        [self.getCodetimer invalidate];
        self.getCodetimer = nil;
    }
}
全部评论

相关推荐

05-22 09:23
门头沟学院 Java
点赞 评论 收藏
分享
frutiger:逆天,我家就安阳的,这hr咋能说3k的,你送外卖不比这工资高得多?还说大厂来的6k,打发叫花子的呢?这hr是怎么做到说昧良心的话的
找工作时遇到的神仙HR
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务