我們在使用 Xamarin.Forms 的 ZXing Barcodescanner 時遇到問題。掃描儀在 Android 上完美運行,但在 IOS 上我看不到相機圖像(預覽)。如果我將條碼放在相機前,掃描儀確實可以掃描 IOS 上的條碼,但相機預覽只是白色背景。我嘗試使用這些選項,但沒有運氣。我們使用 Prism.Forms 進行 MVVM。正如我提到的,我的代碼在 Android 上運行良好。以下是一些細節:兩個平臺上的權限均已正確設置。NuGets ZXing.Net.Mobile 和 ZXing.Net.Mobile.Forms 也添加到所有三個項目(Android、IOS 和便攜式)我們正在使用 .NET Standard 2.0Xamarin.Forms 版本為 3.4.0ScannerView.xaml<forms:ZXingScannerPage xmlns="http://xamarin.com/schemas/2014/forms"? ? ? ? ? ? ? ? ? ? xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"? ? ? ? ? ? ? ? ? ? xmlns:forms="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms"? ? ? ? ? ? ? ? ? ? x:Class="App.Portable.View.ScannerView"><ContentPage.Content>? ? <Grid>? ? ? ? <Grid.RowDefinitions>? ? ? ? ? ? <RowDefinition Height="*"/>? ? ? ? </Grid.RowDefinitions>? ? ? ? <forms:ZXingScannerView x:Name="scanner" Grid.Column="0" Grid.Row="0" HorizontalOptions="EndAndExpand" VerticalOptions="FillAndExpand"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IsScanning="{Binding IsScanning}"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IsAnalyzing="{Binding IsAnalyzing}"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Result="{Binding Result, Mode=TwoWay}"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ScanResultCommand="{Binding CmdScanResult}"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Options="{Binding ScannerOptions}"? ? ? ? />? ? ? ? <forms:ZXingDefaultOverlay Grid.Column="0" Grid.Row="0"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TopText="Some title"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ShowFlashButton="False"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?BottomText="Some bottom text"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Opacity="0.9"/>? ? </Grid></ContentPage.Content>有人在我的代碼中發現問題,或者對如何做得更好或至少讓它工作有一些建議嗎?
1 回答

慕尼黑5688855
TA貢獻1848條經驗 獲得超2個贊
原因:您將ZXingScannerView和ZXingDefaultOverlay放在網格的同一單元格中。然后將ZXingScannerView設置HorizontalOptions
為 。EndAndExpand
解決方案:
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
- 1 回答
- 0 關注
- 123 瀏覽
添加回答
舉報
0/150
提交
取消