Several methods of iOS anti-repeated clicks

Source: Internet
Author: User

1. global variable flag method

@property (nonatomic,assign) boolisclickedflag;//prevent repeated clicks
#pragma mark--global variable flag method
-(void) ljbtnclicked
{
    if (Self.isclickedflag ==yes)
    {
        Self.isclickedflag =no;
        function//own function
        {
           Do what you need to do, then open click
           self.isclickedflag =yes
        }
}


2. Delay Call Method

Delay 0.5s to perform
 [selfperformselector: @selector (ljbtnclicked) withobject:nilafterdelay:0.5];

 Dispatch_after (Dispatch_time (Dispatch_time_now, int64_t) (0.5 * nsec_per_sec)),  Dispatch_get_main_queue (), ^{
                  [Self ljbtnclicked];//Delay execution
                }];

3. Class Delay method

You just need to set a property time.

Refer to this article http://www.jianshu.com/p/8e562c24039e


4. Set the Click UI property to No (most effective method)

[_btnnode Setcontrolnodeenable:no];
 
      Dispatch_after (Dispatch_time (Dispatch_time_now, int64_t) (0.5 * nsec_per_sec)), Dispatch_get_main_queue (), ^{
                    [ Self ljbtnclicked];//delay execution
                    [_btnnode setcontrolnodeenable:yes];
                };



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.