Notification of or detecting screenshot before bei

2019-01-03 17:26发布

Is there a notification or other mechanism of being informed that the user is taking a screenshot with the home/power buttons?

I've seen threads about wanting to disable the taking of screenshots, but that's not what I'm looking to do.

I have a photographer client who's concerned that his works will be copied by means of users taking screenshots and I thought that if there was an opportunity to put a watermark across the image before the screenshot was taken, that would allay his fears.

5条回答
在下西门庆
2楼-- · 2019-01-03 17:32

What's really needed is a notification that is sent before the actual screen capture happens. A delegate method or some other means of giving the app a screenshotting-in-flight opportunity to redraw your content before the grab happens.

And there isn't one.

查看更多
Root(大扎)
3楼-- · 2019-01-03 17:36

Since iOS 7 the UIApplicationUserDidTakeScreenshotNotification exists. So doing something like this should detect the screenshots:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDidTakeScreenshot) name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}

- (void)userDidTakeScreenshot {
    // Screenshot taken, act accordingly.
}

Finally, don't forget to remove the observer:

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}
查看更多
做个烂人
4楼-- · 2019-01-03 17:39

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

(No notifications will be sent before the screenshot was taken.)

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-03 17:48

Here's a way which might work, although it will totally go against user interface guidelines I'm sure. If you force the user to have their finger on the screen for the image to show then I don't think they can create screenshots. Because as soon as you press the home+lock keys to actually take the screenshot, the screen seems to behave as if there are no fingers touching it. Try taking a screenshot while moving between home screens to see what I mean.

Not a perfect solution by any means but you may be able to work it into your app design if you're really clever without it detracting too much from the user experience (a tough challenge though!). Nevertheless, I believe this may allow you to display artwork/photos without allowing users to take screenshots.

查看更多
6楼-- · 2019-01-03 17:49

BY USING THIS ANSWER YOU GET NOTIFY AFTER TAKING SCREENSHOT.

iOS 11 and Swift 4

Three Simple Steps:-

1. Add the following

查看更多
登录 后发表回答