Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-13-2009, 01:44 PM   #1 (permalink)
New Member
 
Join Date: Feb 2009
Posts: 1
Default 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)startid)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
AcousticBlue is offline   Reply With Quote
Old 03-10-2009, 06:52 PM   #2 (permalink)
New Member
 
Join Date: Mar 2009
Location: Covina, California - United States
Age: 28
Posts: 22
Default

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.
Legrend is offline   Reply With Quote
Old 07-08-2009, 06:06 PM   #3 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 1
Default

Quote:
Originally Posted by AcousticBlue View Post
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
skiptrace is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 453
12 members and 441 guests
clerisysolutions, dana0550, dapis, darbsllim, dre, Harolano, Hyde, lbert, leesdesjardins, marshusensei, Objective Zero, RickSDK
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 157,851
Threads: 88,914
Posts: 379,294
Top Poster: BrianSlick (7,072)
Welcome to our newest member, darbsllim
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:09 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0