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]