0

So I am using a 3rd party lib for scanning barcodes - shopsavvy. What I am trying to do is to show a new screen with all scanned barcode once the scanner is dismissed. I have done (what I thought is pretty straightforward) the following, but not getting the new screen, rather going back to the original screen after the scanner is dismissed.

What am I doing wrong?

This is in my main view controller:

- (void) scannerViewController:(SKScannerViewController *)scanner didRecognizeCode:(SKCode *)code {
NSLog(@"didRecognizeCode = %@", code.rawContent);

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

[self dismissModalViewControllerAnimated:YES]; //We're done scanning barcodes so we should dismiss our modal view controller.

_codeInfoLabel.text = code.rawContent; 

[self showResults:code.rawContent];

}

I am getting into this method and its being executed, but nothing happens.

 - (void) showResults: (NSString *) barcode {

Results *resultsViewController = [[Results alloc] initWithNibName:nil bundle:nil];
resultsViewController.tempBarcode = barcode;
UINavigationController *resultsNavigationController = [[UINavigationController alloc] initWithRootViewController:resultsViewController];
resultsNavigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:resultsNavigationController animated:YES];

}
9
  • What happens if you just present the resultsViewController instead of adding it to the navigation controller first?
    – Jakob W
    Nov 1, 2011 at 15:23
  • same thing - nothing happens.
    – TommyG
    Nov 1, 2011 at 15:25
  • Perhaps you shouldn't use the initWithNibName method unless you have a nib file, but initWithFrameinstead?
    – Jakob W
    Nov 1, 2011 at 16:13
  • Can you present any other view controller?
    – Jakob W
    Nov 1, 2011 at 16:24
  • I dont have any...when the scanner dismisses itself, I go back to the main page (instead of the results page), and there, I can click on "scan" to launch the scanner again - that works.
    – TommyG
    Nov 1, 2011 at 16:29

2 Answers 2

1

The only way I could get this type of thing to work was to pop back to the original controller when the scanner view was dismissed.

Then, in your "view will appear" check some type of status set in the scanning process, maybe set in prefs, like "scanner complete". If so, launch the results display.

1
  • do you mean in the "view will appear" of the view from which I pushed the scanner? (where the "Scan" button is?). I am not sure I have any indication of that, but sounds in theory the best solution so far.
    – TommyG
    Nov 1, 2011 at 22:39
0

Surely it makes more sense just to pop straight to the results page rather then dismissing it then loading a new view.

[self.navigationController popToViewController:resultsViewController animated:YES];
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.