How to detect if user did a screenshot with home+p

2019-07-01 14:02发布

I'm trying to detect if user take a screenshot in order to warn them this is a video with copyright. I've tried Darwin Notification, but it didn't work... NSMetadataQuery might be a solution, but we want the app to run on iOS4 as well. Can somebody help me? Thanks!:p

3条回答
Juvenile、少年°
2楼-- · 2019-07-01 14:35

before ios 4.0 you can register for PictureWasTakenNotification .This notification is sent when screenshot is taken.No notifications will be sent before the screenshot was taken. But after that this has been discontinued and IMHO there is no other way round... :/

查看更多
beautiful°
3楼-- · 2019-07-01 14:41

It is not possible to detect a screenshot has (or will) be taken on iOS 5.

In iOS 4.0, there was a Darwin notification fired PictureWasTakenNotification, but not anymore.

The documentation does not mention anything, and using NSNotificationCenter to subscribe to all notifications only shows silence after taking a screenshot.

查看更多
叼着烟拽天下
4楼-- · 2019-07-01 14:45

you can detect it with adding an observer to UIApplicationUserDidTakeScreenshotNotification .

NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification
              object:nil
               queue:mainQueue
          usingBlock:^(NSNotification *note) {
             // executes after screenshot
}];
查看更多
登录 后发表回答