条形码扫描仪无法在纵向模式下使用Xamarin格式

时间:2017-05-17 06:52:24

标签: ios xamarin.forms zxing

我正在iOS设备中通过此code使用ZXing处理PDF417条码扫描器。条形码扫描在横向模式下工作正常,但在纵向模式下不起作用。

我也尝试改变一些关于方向改变但没有成功。有没有人遇到类似的类型问题?任何想法或建议都会很棒。

为Orientation,下面是代码

public void ResizePreview (UIInterfaceOrientation orientation)
    {
    if (previewLayer == null)
        return;

    previewLayer.Frame = new CGRect (0, 0, this.Frame.Width, this.Frame.Height);

    if (previewLayer.RespondsToSelector (new Selector ("connection")) && previewLayer.Connection != null)
    {
        switch (orientation)
        {
            case UIInterfaceOrientation.LandscapeLeft:
                previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.LandscapeLeft;
                break;
            case UIInterfaceOrientation.LandscapeRight:
                previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.LandscapeRight;
                break;
            case UIInterfaceOrientation.Portrait:
                previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.Portrait;
                break;
            case UIInterfaceOrientation.PortraitUpsideDown:
                previewLayer.Connection.VideoOrientation = AVCaptureVideoOrientation.PortraitUpsideDown;
                break;
        }
    }
}

用于捕获下面的条形码是代码

buttonScanDefaultOverlay.Clicked += async delegate {
            var options = new ZXing.Mobile.MobileBarcodeScanningOptions {
                    TryHarder = true,
                    //CameraResolutionSelector = HandleCameraResolutionSelectorDelegate,
                    PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.PDF_417 }
                };
                //options = ZXing.Mobile.MobileBarcodeScanningOptions.(HandleCameraResolutionSelectorDelegate);

                scanPage = new ZXingScannerPage (options);
                scanPage.OnScanResult += (result) => {
                    scanPage.IsScanning = false;

                    Device.BeginInvokeOnMainThread (() => {
                        Navigation.PopAsync ();
                        DisplayAlert("Scanned Barcode", result.Text, "OK");
                    });
                };

                await Navigation.PushAsync (scanPage);
            }; 

0 个答案:

没有答案