"Get verification code" and "get verification code"

Source: Internet
Author: User

"Get verification code" and "get verification code"

When it comes to the user registration function, many apps now use mobile phone numbers as the basis for registration, which naturally cannot be separated from mobile phone verification codes. To prevent repeated clicks, a countdown is usually displayed. After a user clicks the button, the button becomes grayed out, and is displayed xx seconds later. After the countdown, the button is restored.

It is not difficult to implement it. You can use NSTimer or GCD for timer. But there are several things to note:

1. About the control selection, is it UIButton or UILabel?

On the surface, it seems that the UIButton implementation should be very simple. The UIButton itself has a click event, and the second is to control the UIButton color and whether it can be clicked (userInteractionEnabled. However, when the countdown starts, the UIButton text changes every second will flash (the screen should be supplemented by your own brain ).
Therefore, I chose UILabel to add a tap gesture to it to implement click events. The disadvantage is that there is no click feedback effect.

2. After a user clicks get verification code, the user returns (the view is pop or dismiss), and then enters the view (push or present). The "get verification code" status becomes clickable again, there is still the possibility of repeated clicks in a short time. In this case, it is hard to say that he has a vulnerability, but some people may think it is very serious.
If it is unfortunate that this group has your leader, product manager, or tester (I am an unfortunate group, you have to fix this "bug ".
I have implemented the above functions and encapsulated the relevant code into a tool class. The code is put on github. Here is the link.

The final results are as follows:

Related Article

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.