0

Im running a function under didFinishPickingMediaWithInfo but how can i render another viewController after the function finish

- (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];
    }];

}

i tried adding

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

after

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

and the view is rendered, but data from [self procesarCheckInConQR:qr]; isnt ready yet

Update: Instead of dismiss i present the new view controller, but i still dont have data from procesarCheckInConQR:qr

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"rootCarta"];
[reader presentViewController:newTopViewController animated:YES completion:^{
    [self procesarCheckInConQR:qr];
}];
jtomasrl
  • 1,430
  • 3
  • 13
  • 22

1 Answers1

0

You have to make your call inside the block after [self procesarCheckInConQR:qr]

KDaker
  • 5,899
  • 5
  • 31
  • 44
  • Warning: Attempt to present on whose view is not in the window hierarchy! – jtomasrl Nov 12 '13 at 19:06
  • @jtomasrl You can't present a new controller from the just dismissed image picker. – rmaddy Nov 12 '13 at 19:14
  • so instead dismissing the image picker i render the view and attach the function to the completion option. But the view is rendered before i can get the data from the function inside completion – jtomasrl Nov 12 '13 at 19:56