直接上代码, 就 一个通知的方法
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];
}