iOS Simple Countdown Verification code number of seconds process implementation

Source: Internet
Author: User

    1. Timer = [Nstimer scheduledtimerwithtimeinterval:1.0 target:self selector: @selector (timerfiremethod:) userinfo:nil Repeats:yes];
  1. Countdown Method Verification code implementation Countdown 60 seconds, 60 seconds after the start of the button transformation
  2. -(void) Timerfiremethod: (Nstimer *) Thetimer {
  3. if (seconds = = 1) {
  4. [Thetimer invalidate];
  5. seconds = 60;
  6. [Validcodebtn_ settitle:@"Get Verification Code" 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. If the login succeeds, stop the reciprocal of the Verification Code,
  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. }

iOS Simple Countdown Verification code number of seconds process implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.