所以我使用第 3 方库来扫描条形码 - shopavvy。我想做的是在扫描仪关闭后显示一个包含所有扫描条形码的新屏幕。我已经完成了(我认为非常简单)以下操作,但没有获得新屏幕,而是在扫描仪关闭后返回到原始屏幕。
我做错了什么?
这是在我的主视图 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];
}
我正在进入这个方法并执行它,但没有任何反应。
- (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];
}
最佳答案
我能让这种类型的东西发挥作用的唯一方法是在扫描仪 View 消失时弹回到原始 Controller 。
然后,在“将出现的 View ”中检查扫描过程中设置的某种类型的状态,可能在首选项中设置,例如“扫描仪完成”。如果是这样,启动结果显示。
关于iphone - 无法推送新的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7968593/