Xamarin RelativeLayout中的布局不';不响应iOS中的输入
在iOS中,点击内部布局(在本例中为向上长点击)时不会触发点击事件。在Android上工作得非常好。我尝试过更新Xamarin.表单,使用普通手势识别器,使用Mr.手势,都得到了相同的结果。我做错了什么?有谁能帮帮我吗?我已经试了好几个星期了。谢谢你抽出时间Xamarin RelativeLayout中的布局不';不响应iOS中的输入,xamarin,xamarin.forms,Xamarin,Xamarin.forms,在iOS中,点击内部布局(在本例中为向上长点击)时不会触发点击事件。在Android上工作得非常好。我尝试过更新Xamarin.表单,使用普通手势识别器,使用Mr.手势,都得到了相同的结果。我做错了什么?有谁能帮帮我吗?我已经试了好几个星期了。谢谢你抽出时间 <RelativeLayout BackgroundColor="White"> <xlabs_c:GesturesContentView x:Name="MainLayout" ExcludeChild
<RelativeLayout BackgroundColor="White">
<xlabs_c:GesturesContentView x:Name="MainLayout"
ExcludeChildren ="False"
Padding="10"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}">
<RelativeLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ContentView
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}">
<xlabs_b:Gestures.Interests>
<xlabs_b:GestureCollection>
<xlabs_b:GestureInterest GestureType="Up" GestureCommand="{Binding OnMainLayoutRetractSidebarCommand}"/>
<!--<xlabs_b:GestureInterest GestureType="Swipe" Direction="Left" GestureCommand="{Binding OnMainLayoutSwipedCommand}"/>
<xlabs_b:GestureInterest GestureType="Swipe" Direction="Right" GestureCommand="{Binding OnMainLayoutSwipedCommand}"/>-->
</xlabs_b:GestureCollection>
</xlabs_b:Gestures.Interests>
<RelativeLayout x:Name="LayoutWrapper" HorizontalOptions="Center" VerticalOptions="Center">
<Image x:Name="BackgroundImage" Aspect="AspectFill" SizeChanged="OnBackgroundImageSizeChanged"/>
<RelativeLayout x:Name="PinsLayout"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToView,
Property=Width,
Factor=1,
ElementName=BackgroundImage}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToView,
Property=Height,
Factor=1,
ElementName=BackgroundImage}"/>
<xlabs_b:Gestures.Interests>
<xlabs_b:GestureCollection>
<xlabs_b:GestureInterest GestureType="LongPress" GestureCommand="{Binding OnLayoutWrapperTappedCommand}"/>
</xlabs_b:GestureCollection>
</xlabs_b:Gestures.Interests>
</RelativeLayout>
</ContentView>
<ContentView InputTransparent="True"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}">
<StackLayout x:Name="PageNumberLayout" InputTransparent="True" Orientation="Horizontal" HeightRequest="50" HorizontalOptions="Center" VerticalOptions="End"/>
</ContentView>
</RelativeLayout>
</xlabs_c:GesturesContentView>
<StackLayout x:Name="SidebarLayout"
Padding="10"
BackgroundColor="{StaticResource Primary}"
Opacity="0"
IsVisible="False"
IsEnabled="False"
Spacing="10"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=Constant,
Property=Width,
Constant=400}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}">
<StackLayout x:Name="FloorListLayout" IsVisible="False" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Frame CornerRadius="10" BackgroundColor="{StaticResource Primary}" Padding="10">
<Label Style="{StaticResource DefaultInvertLabel}" Text="{x:Static resx:LanguageResources.SortFloorText}" FontSize="Medium" TextColor="{StaticResource LightBackgroundColor}" VerticalOptions="CenterAndExpand"/>
</Frame>
<ListView x:Name="FloorListView"
ItemsSource="{Binding Floor}"
HasUnevenRows="False"
IsPullToRefreshEnabled="False"
CachingStrategy="RecycleElement"
ItemSelected="OnFloorListViewItemSelected"
SeparatorVisibility="Default"
SeparatorColor="{StaticResource Accent}"
BackgroundColor="{StaticResource Primary}"
RowHeight="75">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="10">
<Frame Padding="5" CornerRadius="10" HorizontalOptions="Start" VerticalOptions="CenterAndExpand">
<Image Source="{Binding ImageSourceBytes, Converter={StaticResource IBytesToImageSourceConverter}}" />
</Frame>
<Label Style="{StaticResource DefaultInvertLabel}" Text="{Binding Name}" FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout x:Name="DefectListLayout" IsVisible="False" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<!-- Function is obsoleted until further notice -->
<!--
<Button x:Name="MasterDefectButton" Text="{x:Static resx:LanguageResources.MasterDefectSelectLabelText}" Clicked="OnMasterDefectButtonClicked"/>
<Button x:Name="DefectButton" Text="{x:Static resx:LanguageResources.DefectSelectLabelText}" IsVisible="False" Clicked="OnDefectButtonClicked"/>
<Button x:Name="SubDefectButton" Text="{x:Static resx:LanguageResources.SubDefectSelectLabelText}" IsVisible="False" Clicked="OnSubDefectButtonClicked"/>
-->
<Frame CornerRadius="10" BackgroundColor="{StaticResource Primary}" Padding="10">
<Label Style="{StaticResource DefaultInvertLabel}" Text="{x:Static resx:LanguageResources.SortDefectText}" FontSize="Medium" TextColor="{StaticResource LightBackgroundColor}" VerticalOptions="CenterAndExpand"/>
</Frame>
<ListView x:Name="DefectsListView"
ItemsSource="{Binding Defects}"
HasUnevenRows="False"
IsPullToRefreshEnabled="False"
CachingStrategy="RecycleElement"
ItemSelected="OnDefectListViewItemSelected"
SeparatorVisibility="Default"
SeparatorColor="{StaticResource Accent}"
RowHeight="75">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10">
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand">
<Label Style="{StaticResource DefaultInvertLabel}" Text="{Binding ID}" FontSize="Medium" HorizontalOptions="Start"/>
<Label Style="{StaticResource DefaultInvertLabel}" Text=". " FontSize="Medium" HorizontalOptions="Start"/>
<Label Style="{StaticResource DefaultInvertLabel}" Text="{Binding Title}" FontSize="Medium" HorizontalOptions="StartAndExpand"/>
</StackLayout>
<Label Style="{StaticResource DefaultInvertLabel}" Text="{Binding Description}" FontSize="Default" HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</RelativeLayout>
由于相对布局具有Z-顺序,因此您很有可能用长按注册来掩盖视图。在android中(如果我没记错的话),你可以有一堆手势识别器,每一个都返回它是否处理了触摸事件。事件最终将沿着视图堆栈向上运行,直到其被处理或未被处理;这使得它在iOS无法。。如果您提供一个屏幕截图并突出显示问题所在,这可能会有所帮助。我也尝试过仅使用一个内部只有一个StackLayout的RelativeLayout。我得到了同样的结果。