Get Updates By E-mail 

Article Written By:
Johann Dowa

Open Source iOS Library For Detecting When A User Is Taking A Screenshot

  •  
  •  
  •  
  •  
  •  

There are a number of apps that detect whether or not the user has taken a screenshot such as Snapchat and the Facebook app.

There have also been a few ideas on exactly how to do perform this detection.

Here’s library from Clay Allsop called ShotBlocker uses a simple technique to detect if the user has taken a screenshot by polling the camera roll based on a timer and checking if a new image has been added that matches the size of the user’s screen.

The library executes a callback block when a new screenshot is detected.

You can find ShotBlocker with usage instructions on Github here.

A simple solution to this problem. Chpwn has written on his blog about how taking screenshots cancels all screen touches so possibly using UILongPressGestureRecognizer and looking for the state to be UIGestureRecognizerStateCancelled rather than polling based on a timer could be a better approach.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments