【问题标题】:Xamarin.Forms AbsoluteLayout issue on iOSiOS 上的 Xamarin.Forms AbsoluteLayout 问题
【发布时间】:2015-11-19 23:35:53
【问题描述】:

我是 xamarin 的新手,我正在尝试在主列表视图顶部使用带有结果列表视图(隐藏)的搜索栏(即:移动 facebook 朋友搜索) 在 iOS 上,我无法点击主列表视图,因为结果列表视图始终位于另一个列表视图之上,即使它不可见。

代码如下:

<AbsoluteLayout>
                <StackLayout Orientation="Vertical" Padding="0,50,0,0">
                    <StackLayout Padding="20,0,0,10">
                        <Label Text="{Binding SelectedAddressString, StringFormat='BCLs near {0}'}" />
                    </StackLayout>
                    <ListView x:Name="iOSlstBCLs" ItemsSource="{Binding BCLList}" IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing, Mode=OneWay}">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextCell Text="{Binding Name}" />
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
                <StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" VerticalOptions="Fill" AbsoluteLayout.LayoutFlags="WidthProportional" AbsoluteLayout.LayoutBounds="0,0,1,1">
                    <SearchBar Text="{Binding SearchText, Mode=TwoWay}" Placeholder="Search" AbsoluteLayout.LayoutFlags="WidthProportional" AbsoluteLayout.LayoutBounds="0,0,1,1" />
                    <ListView IsVisible="{Binding IsSuggestionListVisible, Mode=OneWay}" ItemsSource="{Binding SuggestionList}" SelectedItem="{Binding SelectedAddress}" VerticalOptions="Fill" AbsoluteLayout.LayoutFlags="WidthProportional" AbsoluteLayout.LayoutBounds="0,0,AutoSize,AutoSize" BackgroundColor="White">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <TextCell Text="{Binding formatted_address}" />
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
            </AbsoluteLayout>

有什么想法吗?

【问题讨论】:

  • 如果将建议 ListView 上的 InputTransparent 绑定到 IsSuggestionListVisible 会发生什么?

标签: ios xamarin xamarin.forms


【解决方案1】:

根据我的经验,尽可能不要使用绝对布局。似乎最好使用堆栈并将其他两个堆栈都放在其中。然后根据需要设置可见性。我不是很肯定,但我猜绝对布局把你弄乱了。

【讨论】:

  • “根据我的经验,如果可能的话,你永远不应该使用绝对布局。” - 你能详细说明一下吗?我们最近几个月才开始使用 Xamarin,发现绝对布局很有帮助,但只有在没有负面影响的情况下才想使用它。
  • 我不记得我是从哪里得到这些信息的,因为已经有一段时间了,但我知道使用绝对布局存在更多的性能问题。我可以告诉你,在 Android 原生平台上也不鼓励使用 Absolutes Layouts,我很确定这是用来实现它的。从 Forms 版本 1.5.2 开始,它说为防止出现性能问题,您不应尽可能使用自动调整大小。 developer.xamarin.com/releases/xamarin-forms/xamarin-forms-1.5/… 这有帮助吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-20
  • 1970-01-01
相关资源
最近更新 更多