A 1-minute countdown specific code is required when a mobile registration or verification requirement is needed:
-(void) viewdidload {[Super viewdidload];
Additional setup after loading the view, typically from a nib.
Self.remainseconds = 60;
Self.startchecktimer = 1;
Self.label = [[UILabel Alloc]initwithframe:cgrectmake (50, 80, 200, 20)];
Self.label.backgroundColor = [Uicolor Redcolor];
[Self.view AddSubview:self.label];
[Self settime];
}-(void) settime{@weakify (self); racsignal* signal = [[[Racsignal interval:1 Onscheduler:[racscheduler Mainthreadschedule
R]] startwith:[nsdate Date]] Map:^id (nsdate* value) {@strongify (self);
if (self.remainseconds > 0 && self.startchecktimer) {self.remainseconds = self.remainseconds-1;
if (Self.remainseconds = = 0) {self.startchecktimer = 0;
}} nsstring *text = [NSString stringwithformat:@ "did not receive the verification code? Please wait for%d seconds", self.remainseconds]; return text;
}]; [Signal subscribenext:^ (NSString* x) {@strongify (self);
Self.label.text = x;
}];
RAC (Self.resendbutton, enabled) = [Racsignal combinelatest:@[
Racobserve (self, remainseconds),
Racobserve (self, Startchecktimer)] Reduce:^id (nsnumber* remain, nsnumber* Startcheck) {return@ (remain.in
TValue = = 0 && _startchecktimer = = 0);
}];
}-(void) Setresendbutton:button {_resendbutton = button;
@weakify (self); [[Self.resendbutton Rac_signalforcontrolevents:uicontroleventtouchupinside] subscribenext:^ (ID x)
{@strongify (self);
self.reSendButton.enabled = FALSE;
Self.remainseconds = 60;
Self.startchecktimer = 1; [Self startResendverifycode];
}];
}
The above simple implementation of the countdown 60s