在捕获 QR 数据后,我试图在 Zbar 委托方法中执行转场,但我没有成功我认为与委托方法和转场的调用有关。我的想法是对另一个视图执行 segue 并在那里显示 QR 扫描结果,我使用 segue 方法并将 QR 值传递给 descuentoController:
- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// ADD: get the decode results
id<NSFastEnumeration> results =
[info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// EXAMPLE: just grab the first barcode
break;
// EXAMPLE: do something useful with the barcode data
self.encodedQR = [encriptationData Midesencriptacion:symbol.data llave:@"RR4$t%%"];
resultText.text = [encriptationData Midesencriptacion:symbol.data llave:@"RR4$t%%"];;
// EXAMPLE: do something useful with the barcode image
resultImage.image =
[info objectForKey: UIImagePickerControllerOriginalImage];
NSLog(@"Valor QR %@", resultText.text);
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
[self segue];
}
-(void) segue{
[self performSegueWithIdentifier:@"descuentoSegue" sender:self];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"descuentoSegue"])
{
descuentoController *vc = ( descuentoController *)[segue destinationViewController];
vc.encodedQR = self.encodedQR;
}
}
谢谢