在我的應用程序中,我已經集成了Zbar SDK掃描儀,雖然通常掃描它的工作正常,但我的情況是有些時候didfinishpickingmediawithInfo:委託方法發射兩次。這是我的代碼,是在一個單獨的課。Zbar sdk掃描儀不能正常工作
-(void)scanProductBarCode
{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
reader.supportedOrientationsMask = ZBarOrientationMaskLandscape;
else
reader.supportedOrientationsMask = ZBarOrientationMaskPortrait;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_UPCA config: ZBAR_CFG_ENABLE to: 1];
[scanner setSymbology: ZBAR_CODE39 config: ZBAR_CFG_ADD_CHECK to: 0];
}
#pragma mark - Scanner delegate methods
- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
break;
barCodeString = [[NSString alloc] initWithString:symbol.data];
if(self.delegate)
[self.delegate getBarcodeString:barCodeString];
[reader dismissModalViewControllerAnimated:YES];
}
看到這樣的畫面截圖:
在後臺掃描仍在運行像這樣在兩次存在的情況下..
謝謝,但加入這個布爾標誌後,委託方法gerbarcodeString:在觸發一次。但是,在兩次觸發didFinishPickingMediaInfo:委託方法的情況下,首次完成條形碼掃描,並且掃描器視圖仍然不會從應用程序中退出。請參閱上面添加的圖像。 – Ganapathy 2013-03-01 08:35:47