c# - Xamarin Forms Tap手势识别器Ios不起作用
<p><p>我的 <code>Xamarin</code> Forms 项目中有一些手势识别器的问题。
我正在努力将三个图像设置为网格层,以查看带有 <code>Zxing</code> 表单库的取景器以进入特定页面并管理闪光灯相机设备。</p>
<p>在我编译并构建我的项目后,Android 设备可以完美运行,除了 Ios,当我触摸它们的图像时,它们根本无法运行。我写代码没有错。</p>
<p>例如点击识别器是这样写的:</p>
<pre><code>var settingsGestureRecognizer = new TapGestureRecognizer();
settingsGestureRecognizer.NumberOfTapsRequired = 1;
settingsGestureRecognizer.Tapped += async(s, e) =>
{
// handle the tap
NavigationPage nav = new NavigationPage(new SettingsPage());
await Navigation.PushModalAsync(nav);
};
</code></pre>
<p>另外,我将它添加到 <code>StackLayout</code> 这样的按钮中</p>
<pre><code>settingsImage = new Image
{
Source = ImageSource.FromFile(ConstantStringCollector.iconSettings),
Aspect = Aspect.AspectFit,
WidthRequest = 45,
HeightRequest = 45,
MinimumHeightRequest = 45,
MinimumWidthRequest = 45,
IsEnabled = true
};
settingsImage.GestureRecognizers.Add(settingsGestureRecognizer);
</code></pre>
<p>然后是我的个人布局</p>
<pre><code>StackLayout stackLayoutBottom = new StackLayout
{
IsEnabled = true,
IsVisible = true,
IsClippedToBounds = true,
Padding = new Thickness(20, 20),
BackgroundColor = Color.Black,
Opacity = 0.8,
VerticalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Horizontal,
Children = {
infoImage,
flashImage,
settingsImage
}
};
</code></pre>
<p>有人可以帮助我吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>如果您尝试点击的内容可见,那么我会查看它是否正在获取输入,一种选择是为除图像之外的所有项目打开 InputTransparent 并查看是否让您的图像接收到您输入。</p>
<p>见:<a href="https://developer.xamarin.com/api/property/Xamarin.Forms.VisualElement.InputTransparent/" rel="noreferrer noopener nofollow">InputTransparent</a> </p></p>
<p style="font-size: 20px;">关于c# - Xamarin Forms Tap手势识别器Ios不起作用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/45035811/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/45035811/
</a>
</p>
页:
[1]