Appcelerator模块事件停止触发

时间:2016-04-15 19:29:11

标签: ios objective-c module appcelerator appcelerator-titanium

我有一个原生iOS模块需要定期触发事件。这些活动完美有效......有时候。随机地,他们只是不开火。

在Obj-C中,该按钮使用TiBlob图像在NSNotificationCenter defaultCenter上触发事件。我的模块类侦听此通知,并调用以下函数:

- (void) imageCaptured:(NSNotification *) notification
{
    NSLog(@"[INFO] module notified of image capture event");
    if ([self _hasListeners:IMAGECAPTUREDEVENT])
        [self fireEvent:IMAGECAPTUREDEVENT withObject:notification.userInfo];
    else
        NSLog(@"[INFO] if an image is captured, and there is no one there to listen for it, does an event get fired?");
}

然后在JS中我有一个像这样的eventlistener:

mymodule.addEventListener('imageCaptured', function(e){
    Ti.API.info('image capture event caught in JS.);
});

这在某些时候确实有效。我甚至可以看到Ti.blob对象返回,如果我将其添加到监听器,但其他时间...我看到“[INFO]模块通知图像捕获事件”日志,然后什么也没有。没有错误。没有关于没有听众的聪明路线。并没有“JS中捕获的图像捕获事件”。

0 个答案:

没有答案
相关问题