【问题标题】:Xamarine Shell TitleView Button disappears in iOSXamarin Shell TitleView 按钮在 iOS 中消失
【发布时间】:2021-11-11 07:07:48
【问题描述】:

我正在努力解决这个问题。 在我的内容页面中,我有一个包含标签和按钮的标题视图。 如果我在 android 中执行一切正常,但在 ios 中,按钮会从屏幕右侧消失。

代码:

<Shell.TitleView>
    <Grid
        Margin="0,0,0,0"
        RowDefinitions="auto" 
        ColumnDefinitions="auto,*">
        <Label
            Grid.Column="0"
            Text="{Binding Title}"
            TextColor="{StaticResource TextGray}"
            FontSize="Title"
            VerticalTextAlignment="Center"
            VerticalOptions="Center">
        </Label>
        <Grid
            Grid.Column="1"
            BackgroundColor="Green">
            <ImageButton
            Clicked="ShowSearchPage"
            BackgroundColor="red"
            HorizontalOptions="End"
            Source="search"
            ></ImageButton>
        </Grid>
    </Grid>
</Shell.TitleView>

Result in Android here

Result in iOS here

【问题讨论】:

    标签: ios shell xamarin titleview


    【解决方案1】:

    我试过你的代码,但测试结果有点不同,图标显示不完整,我什至尝试使用 StackLayout而不是outer Gird但没有运气,TitleView占用空间的计算不正确,这是一个潜在的问题,请随时在 github 上提出问题:https://github.com/xamarin/Xamarin.Forms/issues

    对于临时解决方法,您可以在 ImageButton 上设置Margin,虽然丑陋但很有用。

     <ImageButton Margin="0,0,20,0"/>
    

    【讨论】:

    • 是的,很难看,但目前它是唯一可用的解决方法,谢谢
    猜你喜欢
    • 1970-01-01
    • 2016-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多