On or about 6/6/10 8:54 AM, thus spake "Alejandro Marcos Aragón" <alejandro.ara...@gmail.com>:
> If the user just taps the button, a UISegmentedControl appears, thus this > target is in touch up inside. Now, if the user taps and holds, another type of > control appears after a delay so this has to be done in touch down (because > the user is still holding), and the user should stop holding the button when > the new control appears. Okay, so obviously you then also use performSelector as you were doing, because you have to respond a certain amount of time after the touch starts if the touch has not ended. But you still don't need to add and remove target-action pairs. - (void) tapAndHold { NSLog(@"respond to tap and hold"); } - (void) userDidTouchDown: (id) sender event: (UIEvent*) e { downtime = [e timestamp]; [self performSelector:@selector(tapAndHold) withObject:nil afterDelay:0.4]; } - (void) userDidTouchUp: (id) sender event: (UIEvent*) e { double diff = [e timestamp] - downtime; if (diff < 0.3) { [[self class] cancelPreviousPerformRequestsWithTarget:self]; NSLog(@"respond to tap"); } } The numbers are up to you, of course. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring & Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com