[英]Xamarin Forms - TapGestureRecognizer not working for iOS
I am creating list of image in a loop and attaching a TapGestureRecognizer to each of them to run a method. 我正在循环创建图像列表,并将TapGestureRecognizer附加到每个图像上以运行方法。 It is working on Android but not on iOS.
它适用于Android,但不适用于iOS。 Why is that?
这是为什么? Is there a problem with it being in a Grid or in a ScrollView?
在网格或ScrollView中是否存在问题?
Here is my code: 这是我的代码:
foreach (var i in files)
{
Image image = new Image { Aspect = Aspect.AspectFit };
image.Source = ImageSource.FromUri(new System.Uri(i));
Button button = new Button();
link = i;
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) =>
{
ViewImage(i);
};
image.GestureRecognizers.Add(tapGestureRecognizer);
gridy.Children.Add(image, 0, num);
num++;
}
Here is my Xaml: 这是我的Xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="YHTS.Gallery"
Title="Gallery"
BackgroundColor="Black">
<ScrollView >
<Grid x:Name="gridy">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
</Grid>
</ScrollView>
设置InputTransparent="True"
的中View
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.