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

View Single Post
Old 03-15-2010, 03:51 AM   #11 (permalink)
Jackie
Registered Member
 
Join Date: Mar 2010
Posts: 4
Default

Quote:
Originally Posted by jeff_lamarche View Post
Setting a boolean is a bit kludgey, and will be hard to maintain for other tap situations (triple, quadruple, etc). There actually IS an "official" way to handle this situation described in the documentation. It's described, but Apple does not give sample code.

How you handle it is to call the correct method in each case using performSelector:withObject:afterDelay:, then, in each situation except single-tap, cancel the previous call before it executes (double-tap cancels the single-tap call, triple-tap cancels the double-tap call). This is what it might look like:


Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	UITouch *touch = [touches anyObject];
	NSUInteger tapCount = [touch tapCount];
	
	switch (tapCount) {
		case 1:
			[self performSelector:@selector(singleTapMethod) withObject:nil afterDelay:.4];
			break;
		case 2:
			[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(singleTapMethod) object:nil];
			[self performSelector:@selector(doubleTapMethod) withObject:nil afterDelay:.4];
			break;
		case 3:
			[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(doubleTapMethod) object:nil];
			[self performSelector:@selector(tripleTapMethod) withObject:nil afterDelay:.4];
			break;
		case 4:
			[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(tripleTapMethod) object:nil];
			[self quadrupleTap];
			break;
		default:
			break;
	}

}
@end
Thanks for the answer, it helps me~~
Jackie is offline   Reply With Quote
 

» Advertisements
» Online Users: 305
18 members and 287 guests
ADY, antonwilliams, dacapo, dcool, HemiMG, iosdevjtp, jakerocheleau, leahov, MarkC, masc2279, michelle, morands, MozyMac, nobre84, sly24, smithdale87, thh022, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,720
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:15 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.