简体   繁体   中英

Xamarine Shell TitleView Button disappears in iOS

I'm struggling with this problem. In my content page i have a titleview containing a label and a button. If i execute in android everything works fine but in ios the button disappear out of the right of the screen.

The code:

<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

I tried your code but the testing result is a bit different, the icon is shown incompletely , I even tried to use StackLayout instead of the outer Gird but no luck , the calulation for the space TitleView occupy is incorrect , it is a potential issue , feel free to raise the issue on github : https://github.com/xamarin/Xamarin.Forms/issues .

在此处输入图片说明

And for the temporary workaround , you can set Margin on ImageButton , ugly but useful .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM