我正在使用Apple的ImageCaptureCore
框架以无头方式执行扫描操作。该框架提供了执行扫描的所有功能,而不涉及Apple之间的ICA对话。
现在,我所做的是写了一个符合ICDeviceBrowser
和ICScannerDevice
协议的课程。与此同时,我也设置了他们的代表。只要系统检测到ICA设备,就会触发以下功能:
/* This message is sent to the delegate when a device has been added. This code adds the device to the cameras array. */
- (void)deviceBrowser:(ICDeviceBrowser*)browser didAddDevice:(ICDevice*)addedDevice moreComing:(BOOL)moreComing {
NSLog( @"deviceBrowser:didAddDevice:moreComing: \n%@\n", addedDevice );
if ( addedDevice.type & ICDeviceTypeScanner ) {
addedDevice.delegate = self;
mScannerDevice = (ICScannerDevice*)addedDevice;
mScannerDevice.delegate = self;
NSString * str = [addedDevice name];
char *cpy = (char *)malloc([str length]+1);
strlcpy(cpy, [str UTF8String], [str length] + 1);
mICAScanners.push_back(cpy);
}
mScannersCollected = true;
}
从代码中可以看出,我已为ICScannerDevice
和ICDevice
设置了代理。现在,我调用扫描过程:
[mScannerDevice requestScan];
理想情况下,这应该开始扫描过程,我应该期望对代理的其中一个方法进行回调,例如:
- (void)device:(ICDevice *)device didEncounterError:(NSError *)error {
NSLog( @"device:didEncounterError:error: \n%@\n", error );
}
或:
- (void)scannerDeviceView: (IKScannerDeviceView *)scanner didScanToURL: (NSURL *)url fileData: (NSData *)data error: (NSError *)error {
}
或者至少在已经实施的代表的各种其他方法之一中。但是,我没有得到任何回调,即使在didEncounterError
方法中也没有。
这种行为可能是什么原因?