w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
UIButton runs methods multiple times when clicking fast on UIButton

Try using this :

- (IBAction)startTimerButtonClicked:(UIButton *)sender
{
    UIButton *button = (UIButton*) sender;
    buttonname.userInteractionEnabled = NO;
    if (!self.timerIsRunning) // Run timer only if it's not allready
running
    {
        [self setupTimer]; // Start the timer
    }
    else
    {
        NSLog(@"Timer should pause with secondsCounter: %d and not continue
to run", secondsCounter);
    }
    buttonname.userInteractionEnabled = YES;
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.