 |
 |
|
 |
02-13-2009, 01:44 PM
|
#1 (permalink)
|
|
New Member
Join Date: Feb 2009
Posts: 1
|
UIBarButtonItem not responding to touch
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
|
|
|
03-10-2009, 06:52 PM
|
#2 (permalink)
|
|
New Member
Join Date: Mar 2009
Location: Covina, California - United States
Age: 26
Posts: 22
|
Hey,
I'm kind of new to programming in general and Objective-C, Cocoa, Xcode, and pretty much everything in general, but personally I hate the tunary operator. I would ditch it as it has caused me issues in other API's I've used.
Other than that, I would put a NSLog in your function call.
Code:
- (IBAction)start:(id)sender
{
NSLog(@"Entering: (IBAction)start:(id)sender");
UIBarButtonItem *button = (UIBarButtonItem *)sender;
NSString *title = (timer!=nil) ? @"Start" : @"Stop";
if (timer!=nil)
{
NSLog(@"(timer != nil) == TRUE))";
[timer invalidate];
[timer release];
timer = nil;
}
else
{
NSLog(@"(timer != nil) == FALSE))";
timer = [NSTimer scheduledTimerWithTimeInterval:0.025 target:self selector:@selector(tick) userInfo:nil repeats:YES];
}
[button setTitle:title];
NSLog(@"Exiting: (IBAction)start:(id)sender");
}
Hope this will help a little. I figure any suggestions is better than none.
|
|
|
07-08-2009, 06:06 PM
|
#3 (permalink)
|
|
New Member
Join Date: Jul 2009
Posts: 1
|
Quote:
Originally Posted by AcousticBlue
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?
|
Did you ever get this resolved?
Skip
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 511 |
| 43 members and 468 guests |
| bbc z, BostonMerlin, cjamerlan, CoolApps, coolman, CunningCat, dany88, dbarrett, dda, designomatt, embedded, Gamer211, ggalante, gonk, IphoneSdk, jharrah, Kalimba, LemonMeringue, loobian, markbuchanan, MarkC, Maximilian, MiniRobinho, montage, mquetel, naomipunkclan, Noise, pashik, pieter78, Pring, saul102, Snappy, soulless, StefanL, Tambourin, the1nz4ne, treazer, TunaNugget, Tuszy, wassupdoc, williamlegate, x2on, ZunePod |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,508
Threads: 35,792
Posts: 156,797
Top Poster: smasher (2,449)
|
| Welcome to our newest member, JoelSelwood7 |
|