- (void)registerClicked
{
//设置计时器
self.secondsCoundDown = 60;
self.countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timeFireMethod) userInfo:nil repeats:YES];
//设置按钮不可点击
[self.resentButton setEnabled:NO];
//发出网络请求
RegisterRequestDAL *registerDAL = [RegisterRequestDAL new];
registerDAL.email = self.emailAddress;
registerDAL.password = self.password;
[registerDAL requestWithDelegate:self];
[SVProgressHUD show];
}
//倒计时方法,
- (void)timeFireMethod
{
self.secondsCoundDown --;
//更新按钮倒计时时间
self.time = [NSMutableString stringWithFormat:@"(%lds)Resend validation messages",(long)self.secondsCoundDown];
[self.resentButton setTitle:self.time forState:UIControlStateDisabled];
if (self.secondsCoundDown == 0) {
[self.countDownTimer invalidate];
self.countDownTimer = nil;
//设置按钮可点击
[self.resentButton setEnabled:YES];
[self.resentButton setTitle:@"Resend validation messages" forState:UIControlStateDisabled];
}
NSLog(@"%ld",(long)self.secondsCoundDown);
}
网友评论