The prohibit button can be clicked continuously within a certain period of time.

Source: Internet
Author: User

The prohibit button can be clicked continuously within a certain period of time.

 

This embarrassing problem occurs when you write a project. Some users need to make network requests or some mobile phones get stuck, and the user clicks continuously, it is often seen that two identical controllers are pushed in succession, and of course there are methods for repeatedly calling network requests, and so on ....

 

The stupid way is to turn off the user interaction at each click, and restore the user interaction of this button after the function is implemented.

 

Of course, this method can be fully implemented, but if there are too many code entries, you have to write a lot of repetitive code. Is there a simpler way ???

 

Actually, I write a static library to implement this function.

 

This is the GitHub address:

 

Https://github.com/YouZhiZheShiJingCheng/YZ_button

 

So how to use it is actually very simple. You just need to pull this folder directly into the project.

 

The continuous click events of all buttons must wait for 1 s. (That's simple)

 

Some people say that some buttons do not need to be limited, or whether they can be set by themselves.

 

Of course. You only need to import the file in the PCH file.

 

YZ_Button.h

 

In this way, you can modify the time. Of course, you can also cancel the time.

 

For example:

 

Change Time

 

UIButton * btn = [[UIButton alloc] init];

Btn. s = 1.5;

 

In this case, the consecutive Button clicking event must be separated by 1.5 S.

 

If you don't want to limit it, It's easy. You just need to change the above 1.5 to 520.

 

Btn. s = 520

 

In this way, there will be no restrictions on the button.

 

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.