【问题标题】:iOS ZBAR instantiateViewControllerWithIdentifier after reader didFinishPickingMediaWithInfo阅读器 didFinishPickingMediaWithInfo 后的 iOS ZBAR instantiateViewControllerWithIdentifier
【发布时间】:2013-11-12 18:46:22
【问题描述】:

我在 didFinishPickingMediaWithInfo 下运行一个函数,但是函数完成后如何渲染另一个 viewController

- (void) imagePickerController: (UIImagePickerController*) reader
 didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    id<NSFastEnumeration> results =[info objectForKey: ZBarReaderControllerResults];

    NSString *qr;
    for (ZBarSymbol *symbol in results) {
        NSLog(@"Resultado: %@", symbol.data);
        qr = symbol.data;
    }

    [reader dismissViewControllerAnimated:YES completion:^{
        [self procesarCheckInConQR:qr];
    }];

}

我尝试添加

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rootCarta"];
[reader presentViewController:newTopViewController animated:YES completion:nil];

之后

[reader dismissViewControllerAnimated:YES completion:^{
        [self procesarCheckInConQR:qr];
    }];

视图被渲染,但数据来自 [self procesarCheckInConQR:qr];还没准备好

更新: 我没有解雇我,而是展示了新的视图控制器,但我仍然没有来自的数据 procesarCheckInConQR:qr

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rootCarta"];
[reader presentViewController:newTopViewController animated:YES completion:^{
    [self procesarCheckInConQR:qr];
}];

【问题讨论】:

    标签: ios objective-c zbar-sdk zbar


    【解决方案1】:

    您必须在 [self procesarCheckInConQR:qr] 之后的块内拨打电话

    【讨论】:

    • 警告:尝试在 上显示 ,其视图不在窗口层次结构中!
    • @jtomasrl 您无法从刚刚关闭的图像选择器中显示新控制器。
    • 所以改为关闭图像选择器,我渲染视图并将函数附加到完成选项。但是在我可以从完成中的函数获取数据之前呈现视图
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多