0

我正在使用 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

任何帮助将不胜感激。谢谢!

4

1 回答 1

0

我得到了代码工作,但仍然有几个问题。这是代码:

     SRSScanVINViewController *scanVINViewController = [[SRSScanVINViewController alloc] init];
[pickerController setOverlay:scanVINViewController];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:scanVINViewController];
[navController setModalPresentationStyle:UIModalPresentationFormSheet];
[navController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
    pickerControllerPopover = [[UIPopoverController alloc] initWithContentViewController:pickerController];
    [pickerControllerPopover setDelegate:self];
    [pickerControllerPopover setPopoverContentSize:CGSizeMake(320.0f, 460.0f)];
    [pickerControllerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
}
else
{
    [self presentViewController:pickerController animated:YES completion:nil];
}

这会将弹出框的大小设置为与我的原始控制器(在笔尖中定义)相同的大小。我仍然有几个问题。

控制器在底部的按钮栏中有 4 个按钮。它还有一个 UIImage。我第一次加载这个控制器时,按钮(和按钮栏和 UIImage)要么丢失,要么位于奇怪的地方。如果我通过触摸控制器外部某处的屏幕来关闭弹出控制器并再次加载控制器,则控件都在正确的位置。事实上,除了第一次之外,它们每次都在正确的位置。

有任何想法吗?

于 2012-09-08T18:48:37.063 回答