Ios controls the trigger frequency of button click events
This problem is often encountered in projects:
When a button is clicked, a corresponding click event is triggered. For example, a network request is sent to the server or a pop-up dialog box is displayed.
However, if a user clicks more frequently, the click event will be triggered continuously to confuse the UI.
My solution to this problem is to set a Boolean value.
(1) Click events that interact with the server: Determine the bool value when you click; Set it once before sending the request; change the bool value after the server receives a response.
(2) For serverless interactive click events: determine when you click, set before the dialog box is executed, and set the latency of 0.25 seconds after the dialog box is completed.
Directly Add code
....
@ Property (nonatomic, assign) BOOL hasLiked;
....
-(Void) viewWillAppear :( BOOL) animated
{
[Super viewWillAppear: animated];
Self. hasLiked = YES;
}
-(Void) btnClick :( UIButton *) button
{
_ Weak VSwiperViewController * weakSelf = self;
If (button. tag = 500 ){
NSInteger userAccountScore = [[VUserInfoEntityManager sharedManager] getPrivateUserInfo]. score;
If (userAccountScore <_ fpzGiftprice & self. hasLiked = YES) {// click hasLiked.
Self. hasLiked = NO; // set it before executing the dialog box
[WeakSelf showNotEnoughCoinsAlertView];
Dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t) (0.25 * NSEC_PER_SEC), dispatch_get_main_queue (), ^ {
WeakSelf. hasLiked = YES; // After the pop-up box is complete, the latency is set to 0.25 seconds.
});
}
}