iOS 截屏提醒

直接上代码, 就 一个通知的方法

 NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];

    [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification

                                                      object:nil

                                                       queue:mainQueue

                                                  usingBlock:^(NSNotification*note) {

                                                      //截屏已经发生,可进行相关提示处理

                                                      UIAlertView*alert= [[UIAlertViewalloc]initWithTitle:nilmessage:@"安全提醒]内含付款码,只适合当面使用。不要截图或分享给他人以保障资金安全"delegate:selfcancelButtonTitle:@"确定"otherButtonTitles:nil,nil];

                                                      [alertshow];

                                                  }];


用完之后记得 销毁通知

- (void)dealloc{

    //离开当前控制器  最好移除通知

    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容