Is there a B4i version of this code
I did find this when search www
B4X:
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
Dim no As NativeObject = Me
no.RunMethod("addListener", Null)
End Sub
#if OBJC
- (void)addListener {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_screenshot_taken)
name:UIApplicationUserDidTakeScreenshotNotification object:nil];
}
#end if
Private Sub Screenshot_Taken
Log("Screenshot taken")
End Sub
I did find this when search www
You cannot directly block UIApplicationUserDidTakeScreenshotNotification from firing to prevent a screenshot; it only notifies you after it happens. To actually prevent screen capture, you must apply isSecureTextEntry to a hidden UITextField, which tricks iOS into masking the screen with black.
Implementation in Objective-C
To secure a specific view, use a UITextField set to secureTextEntry.
#if OBJC
- (void)preventScreenCapture {
// 1. Create a UITextField
UITextField *field = [[UITextField alloc] init];
field.secureTextEntry = YES;
// 2. Add to your current view
[self.view addSubview:field];
// 3. Make the secure layer cover your desired content
// Typically requires setting up constraints to fill the screen/view
field.layer.sublayers.firstObject.delegate = self;
// 4. Hide the text field itself
field.hidden = YES;
}
#endif