美文网首页
iOS检测截图

iOS检测截图

作者: 十方树 | 来源:发表于2019-04-11 20:39 被阅读0次

在项目中,有的时候会有这样一个需求,就是检测手机系统截图的操作,并作出相应的处理。iOS7以后苹果为大家提供了一个获取截图的通知,会在截图后调用。

OC:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(takeScreenshotAction) name:UIApplicationUserDidTakeScreenshotNotification object:nil];

Swift:

NotificationCenter.default.addObserver(self, selector: #selector(ViewController.takeScreenshotAction), name: NSNotification.Name.UIApplicationUserDidTakeScreenshot, object:nil)

相关文章

网友评论

      本文标题:iOS检测截图

      本文链接:https://www.haomeiwen.com/subject/qhaxwqtx.html