Reputation: 4155
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];
}
Upvotes: 0
Views: 351
Reputation: 36713
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.
Upvotes: 1
Reputation: 4251
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];
Upvotes: 0