NSOperationQueue *mainQueue = [NSOperationQueuemainQueue];
[[NSNotificationCenterdefaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification object:nilqueue:mainQueue usingBlock:^(NSNotification *note){
[selfjiePing];
}];
-(void)jiePing
{
UIAlertView *alertView=[[UIAlertViewalloc]initWithTitle:nilmessage:@"[安全提醒]内含付款码,只适合当面使用。不要截图或分享给他人以保障资金安全。"delegate:selfcancelButtonTitle:@"绝不给别人"otherButtonTitles:@"仅我自己用",nil];
alertView.tag=105;
[alertView show];
}
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(jiePing) name:UIApplicationUserDidTakeScreenshotNotification object:nil]; //这个写法是针对于当前控制器
离开当前控制器的时候 最好移除通知
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector( jiePing) object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationUserDidTakeScreenshotNotification object:nil];