MRRPlatinum
MRRPlatinum

Reputation: 43

Touch Cancel IBAction

I have an IBAction:

- (IBAction)stop:(id)sender {
    NSLog(@"Called");
    if (timer) {
        [timer invalidate];
        timer = nil;
    }
}

This should stop the timer that is running, I've included the NSLog to to see if my invalidating of the timer is bad or if the method isn't even being called, and, it's not being called. I have my button connected to the "Touch Cancel" method in storyboard, is there anything I can do to make this work? Also, I have a "Touch Down" method for the timer to start:

- (IBAction)begin:(id)sender {
    [timer invalidate];
    timer = [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(doSomething:) userInfo:nil repeats:YES];

}

Upvotes: 1

Views: 531

Answers (1)

drewdahl
drewdahl

Reputation: 194

To have a UIButton fire off an IBAction when it is pressed and released you will want to use the "Touch Up Inside" sent event and not "Touch Cancel".

Upvotes: 1

Related Questions