我正在尝试UIScreenCapturedDidChangeNotification
在我的 Titanium 应用程序中使用超级循环监控屏幕录制状态。我已经尝试了一段时间,但我找不到在超级循环中使用 NotificationCenter 或 addObserver 的任何示例。基本上我试图将以下本机代码带入超级循环,但没有运气:
if (@available(iOS 11.0, *)) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleScreenCaptureChange)
name:UIScreenCapturedDidChangeNotification object:nil];
}
这是我的尝试不起作用:
//Add event listener to monitor screen recording.
var NotificationCenter = require('Foundation/NSNotificationCenter');
var UIScreenMonitor = Hyperloop.defineClass('UIScreenMonitor', 'NSObject');
UIScreenMonitor.addMethod({
selector : 'handleScreenRecording',
instance : true,
arguments : ['NSNotification'],
callback : function(screen) {
alert('Screen recording changed: '+UIScreen.mainScreen.isCaptured());
console.log('Screen recording changed: ',UIScreen.mainScreen.isCaptured(),screen.isCaptured());
}
});
var screenMonitor = UIScreenMonitor();
NotificationCenter.defaultCenter.addObserverSelectorNameObject(screenMonitor,'handleScreenRecording',UIScreen.UIScreenCapturedDidChangeNotification,null);