iphone - 无法推送新的 View Controller

标签 iphone ios xcode uiviewcontroller

所以我使用第 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/

相关文章:

iphone - 得到当前的纬度和经度

Swift:更新标签/HTTP 请求

iphone - 从 UILabel 中删除最后一个值?

iphone - 如何在 objective-c 中读取 MIME 类型的文件

ios - 通过代码访问麦克风进行录音,iOS

ios - 访问 MFMessageComposeViewController 的第一响应者

iOS faSTLane 传递元数据

ios - AdMob iOS,在测试设备上展示广告

iphone - 未在文档目录文件夹中获取图像

ios - 更新到 Swift 1.2 后出错