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.