加入protocol
並實現以下兩個方法:
//成功解讀Barcode時 - (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result;
//Cancel 按鈕按下時 - (void)zxingControllerDidCancel:(ZXingWidgetController*)controller;
再來就是畫面的建立
//建立掃描畫面 ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO]; [widController.overlayView setDisplayedMessage:@"請將條碼圖示置於框線內"]; //Barcode Reader QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init]; NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil]; [qrcodeReader release]; widController.readers = readers; [readers release]; //掃瞄完成時,聲音提示 NSBundle *mainBundle = [NSBundle mainBundle]; widController.soundToPlay =[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO]; //將描畫面加入主畫面 [self presentModalViewController:widController animated:YES]; [widController release];
沒有留言:
張貼留言