2015-06-07 29 views

回答

1

無法阻止iOS屏幕截圖。至少你可以通過這種方式檢測屏幕截圖:

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

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

- (void)viewWillDisappear:(BOOL)animated { 
    [super viewWillDisappear:animated]; 

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

- (void)screenshotDetected { 

    UIAlertView * alert =[[UIAlertView alloc ] initWithTitle:@"Hey!" 
                message:@"You're not allowed to do that" 
                delegate:self 
              cancelButtonTitle:@"Cancel" 
              otherButtonTitles: nil]; 
    [alert addButtonWithTitle:@"GO"]; 
    [alert show]; 
}