I am doing some real basic animation using an NSTimer - it works great. However, I have since tried to have a button update it's title based on whether the animation is on or off and to reset/kill the timer based on the same. (The button is part of a UIToolbar)...
Here is my code:
- (IBAction)start

id)sender
{
UIBarButtonItem *button = (UIBarButtonItem *)sender;
NSString *title = (timer!=nil) ? @"Start" : @"Stop";
if (timer!=nil)
{
[timer invalidate];
[timer release];
timer = nil;
} else {
timer = [NSTimer scheduledTimerWithTimeInterval:0.025 target:self selector:@selector(tick) userInfo:nil repeats:YES];
}
[button setTitle:title];
}
This works great in the simulator. However, on the actual device, it works the first time you touch the start button. However, when you then try to stop it, the button no longer responds to a user touch. I am at a complete loss. Does the UIBarButtonItem change its respondToEvents status when it's title is changed? I would think this would also effect the simulator. The only other thing I can think of is that I am not releasing the NSTimer properly for the device to respond correctly. Can anyone help?
Thanks,
Charles