- timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:YES];
- -(void)timerFireMethod:(NSTimer *)theTimer {
- if (seconds == 1) {
- [theTimer invalidate];
- seconds = 60;
- [validCodeBtn_ setTitle:@"获取验证码" forState: UIControlStateNormal];
- [validCodeBtn_ setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [validCodeBtn_ setEnabled:YES];
- }else{
- seconds--;
- NSString *title = [NSString stringWithFormat:MSG_DYNAMIC_CODE_WAIT,seconds];
- [validCodeBtn_ setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
- [validCodeBtn_ setEnabled:NO];
- [validCodeBtn_ setTitle:title forState:UIControlStateNormal];
- }
- }
- - (void)releaseTImer {
- if (timer) {
- if ([timer respondsToSelector:@selector(isValid)]) {
- if ([timer isValid]) {
- [timer invalidate];
- seconds = 60;
- }
- }
- }
- }
posted @
2014-11-26 18:40
ZLK0011
阅读(
280)
评论()
编辑
收藏
举报