Hello,
On screen I have a numerical value and two buttons. One button increments this value when held and stops incrementing when released. The other button does the same but decreases the value. The 'touch down' events of the buttons kicks off an NSTimer to run the code that will increase / decrease the value. The 'touch up inside' events invalidate the timer.
My problem is that when the button is pressed and held but the user slides their finger away to another part of the screen and then releases it the timer doesn't stop and the values increase or decrease indefinitely (press the button again doesn't help).
I tried having the 'touch up outside' link to the same IBAction code as the 'touch up inside' but this hangs the application.
Here is my 'touch down' code for an increase:
- (IBAction)touchDownIncrease

id)sender;
{
timerIncrease = [[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(holdForIncrease) userInfo:nil repeats:YES] retain];
}
Here is my 'touch up inside' code for an increase:
- (IBAction)touchUpIncrease

id)sender;
{
if ([timerIncrease isValid]) {
[timerIncrease invalidate];
[timerIncrease release];
}
}
Can someone please point me in the right direction.
Thanks,
cartz.
PS. Is there a good description anywhere of the various button events, I just can't seem to find it.