Double Tap for screenshot

I’d like my users to be able to take a screenshot of the app’s current appearance by double-tapping. Can someone point me in the right direction? Perhaps a bit of code? It’s not clear to me how to get double tap events or how to link them to the taking of a screenshot. I did find this code on the web:

  
  
- (UIImage*)captureView:(UIView *)view {  
	CGRect rect = [[UIScreen mainScreen] bounds];  
	UIGraphicsBeginImageContext(rect.size);  
	CGContextRef context = UIGraphicsGetCurrentContext();  
	[view.layer renderInContext:context];  
	UIImage *img = UIGraphicsGetImageFromCurrentImageContext();  
	UIGraphicsEndImageContext();  
	return img;  
}  
   
- (void)saveScreenshotToPhotosAlbum:(UIView *)view {  
	UIImageWriteToSavedPhotosAlbum([self captureView:view], nil, nil, nil);  
}  
  

Assuming your problem is detecting double-tap and not the screenshot part, can you detect single taps?

Double-tap could be emulated as two single-taps within a predetermined interval and within a predetermined target space.

HTH.

Regards,
Abe

//define unsigned long lastTap in testApp.h

void testApp::mousePressed(int x, int y, int button)
{
unsigned long curTap = ofGetElapsedTimeMillis();
if(lastTap != 0 && curTap - lastTap < 250){
//do something
}
lastTap = curTap;

}