From de1d1ee04ff96af08303cc1090c8f8eac21a773b Mon Sep 17 00:00:00 2001 From: Dennis van den Berg Date: Tue, 27 Aug 2024 14:34:14 +0200 Subject: [PATCH] Update BarcodeView for iOS to prevent NullRefrenceException --- BarcodeScanning.Native.Maui/Platform/MaciOS/BarcodeView.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/BarcodeScanning.Native.Maui/Platform/MaciOS/BarcodeView.cs b/BarcodeScanning.Native.Maui/Platform/MaciOS/BarcodeView.cs index d2687c8..62fd11c 100644 --- a/BarcodeScanning.Native.Maui/Platform/MaciOS/BarcodeView.cs +++ b/BarcodeScanning.Native.Maui/Platform/MaciOS/BarcodeView.cs @@ -31,8 +31,9 @@ public override void LayoutSubviews() { _previewLayer.Frame = layer.Bounds; - if (_previewLayer.Connection is not null && _previewLayer.Connection.SupportsVideoOrientation) - _previewLayer.Connection.VideoOrientation = this.Window?.WindowScene?.InterfaceOrientation switch + var connection = _previewLayer.Connection; + if (connection is not null && connection.SupportsVideoOrientation) + connection.VideoOrientation = this.Window?.WindowScene?.InterfaceOrientation switch { UIInterfaceOrientation.LandscapeLeft => AVCaptureVideoOrientation.LandscapeLeft, UIInterfaceOrientation.LandscapeRight => AVCaptureVideoOrientation.LandscapeRight,