我正在使用 RedLaser SDK。我的应用程序是拆分视图。当在主视图控制器上按下条形按钮时,我正在尝试启动 RedLaser 覆盖。
该方法在按下按钮时被调用,这就是问题开始的地方。我有 3 个不同版本的代码来启动覆盖。每个人都有自己的问题。
选项 1 这是我的基线,我知道它不会起作用,因为我没有初始化覆盖。以下代码正确启动视图控制器,但(显然)没有做我想要的。
// Working Code that brings up dialog but doesn't start camera overlay
SRSScanVINViewController *scanVINViewController y= [[SRSScanVINViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:scanVINViewController];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
[navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:navController animated:YES completion:nil];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
选项 2 此代码启动覆盖控制器并启动它而不会崩溃。覆盖正在工作并且相机处于活动状态。问题是 viewcontroller/overlay 占据了整个屏幕。我的控件(按钮等)都布置得好像视图控制器占据了屏幕左上角的一部分。如果我可以正确调整叠加层的大小,这将起作用。
// Working code that shows the overlay (camera on) but the overlay takes the whole screen
SRSScanVINViewController *scanVINViewController = [[SRSScanVINViewController alloc] init];
[pickerController setOverlay:scanVINViewController];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:scanVINViewController];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
[navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:pickerController animated:YES completion:nil];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
选项 3 此尝试是为了解决选项 2(上图)中的问题。这是代码:
SRSScanVINViewController *scanVINViewController = [[SRSScanVINViewController alloc] init];
[pickerController setOverlay:scanVINViewController];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pickerController];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
[navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:pickerController animated:YES completion:nil];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
它崩溃并出现以下错误(nslog):
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <SRSMasterViewController: 0x1f59f540>.'
*** First throw call stack:
(0x37ecb88f 0x331fc259 0x30d86441 0x7f6b5 0x7edf7 0x37e253fd 0x30cbfe07 0x30d855e7 0x37e253fd 0x30cbfe07 0x30cbfdc3 0x30cbfda1 0x30cbfb11 0x30cc0449 0x30cbe92b 0x30cbe319 0x30ca4695 0x30ca3f3b 0x3630522b 0x37e9f523 0x37e9f4c5 0x37e9e313 0x37e214a5 0x37e2136d 0x36304439 0x30cd2cd5 0x7deb5 0x7de50)
terminate called throwing an exception
任何帮助将不胜感激。谢谢!