Possible to detect if a user is pressing the scree

2019-08-12 07:48发布

问题:

I need to know if the user is trying to take a screen capture of a specific section on an app we are building. Any advice would be helpful. We would like to then black out the screen to prevent a screen shot from being taken.

回答1:

No. Its not possible to find out.



回答2:

You cann't control Home and Switch buttons actions. It is the default hardware behaviour.



回答3:

I also believe it to be impossible to detect.

I did a few tests, thinking that the iOS might call

-(void) applicationDidEnterBackground:(UIApplication*)application or

- (void)applicationWillResignActive:(UIApplication *)application

might be called, but NSLogs in those methods weren't called when I took a screenshot.

I did find this but it's also not available in iOS 5.0+. (perhaps even not after iOS 4.0+)

The PictureWasTakenNotification Darwin notification will be sent when the user takes a screenshot. However, this is sent after the screenshot is taken.

[source]