我正在使用zing移动扫描仪,它工作得很好,但是我从一个不同的按钮调用相同的操作,它拒绝扫描,它会弹出预览窗口ok,但不会调用扫描。
public async void BtnScanStockTakeItem_Clicked(object sender, EventArgs e)
{
var scanPage = new ZXingScannerPage();
scanPage.ToggleTorch();
scanPage.IsScanning = true;
await Navigation.PushAsync(scanPage);
scanPage.OnScanResult += (result) =>
{
// Stop scanning
scanPage.IsScanning = false;
// Pop the page and show the result
Device.BeginInvokeOnMainThread(async () =>
{
await Navigation.PopAsync();
}
}然后,我从另一个按钮方法调用上面的方法,比如说saved函数
private async void SaveFunction(object sender, EventArgs e)
{
foreach (var item in transferList)
{
int z = await restServices.PostStockTakeTransaction(item);
}
Preferences.Set("StockTakeWarehouse", pickStockTake.SelectedIndex);
WarehouseName = pickStockTake.SelectedItem.ToString();
bool x = await DisplayAlert("Test", "Item Saved", "ReScan", "Cancel");
if (x)
{
BtnScanStockTakeItem_Clicked(sender, e);
//this is where it rescans the item
}
}字符串的问题是,我没有得到任何logcat错误或什么都没有,扫描仪的视区显示,但就是不接受扫描,因为某些原因,与以前一样的条形码格式。
发布于 2019-09-18 16:15:50
对于任何其他面临类似问题的人来说,事实上我的相机线程没有被正确地调用,我不得不这样做
Device.BeginInvokeOnMainThread(async () =>
{
BtnScanStockTakeItem_Clicked(sender, e);
});按预期工作
https://stackoverflow.com/questions/57976097
复制相似问题