从Shell页面导航到选项卡式页面会导致ios问题。 -Xamarin.forms

时间:2019-11-14 09:04:58

标签: xamarin xamarin.forms

在我的xamarin.forms应用程序中,我正在使用外壳程序组件。我有一个名为 TimeSheetsTab 的选项卡式页面。当我从Shell标签页导航到TimeSheetsTab时,在ios中它仅显示黑页。在Android中,它工作正常。请参考屏幕截图。

ios android

我的Appshell页面

<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"             
             Shell.NavBarIsVisible="False"
             xmlns:local="clr-namespace:Sample.Views"
             x:Class="Sample.AppShell">

    <TabBar>
        <Tab Title="Dashboard" Icon="icon_dashboard.png" >
            <ShellContent ContentTemplate="{DataTemplate local:Dashboard}" />
        </Tab>

        <Tab Title="Notifications" Icon="icon_notifications.png">
            <ShellContent ContentTemplate="{DataTemplate local:Notifications}" />
        </Tab>

        <Tab Title="Account" Icon="icon_user.png">
            <ShellContent ContentTemplate="{DataTemplate local:Account}" />
        </Tab>
    </TabBar>


</Shell>

“我的仪表板”,它是Shell的第一个标签页

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
             mc:Ignorable="d"                   
             Title="Dashboard"            
             x:Class="Sample.Views.Dashboard">
    <ContentPage.Content>
         <Button BackgroundColor="Black"   Clicked="Button_Clicked"   Text="Click to tabpapge"  >                    
         </Button>              
    </ContentPage.Content>
</ContentPage>

按钮单击以导航到选项卡式页面

   private async void Button_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushAsync(new TabPage(), true);           
        }

我的标签页

        <?xml version="1.0" encoding="utf-8" ?>
        <TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Views="clr-namespace:Sample.Views"
             BarBackgroundColor="{DynamicResource NavigationBarColor}"
             mc:Ignorable="d"      
             NavigationPage.HasNavigationBar="False"
             Shell.BackgroundColor="{DynamicResource NavigationBarColor}"
             Shell.NavBarIsVisible="True"
             x:Class="Sample.Views.TimeSheetsTab">
    <Shell.TitleView>
        <StackLayout HorizontalOptions="FillAndExpand" Orientation="Horizontal" >
            <Label FontSize="Medium" Text="Timesheets" HorizontalTextAlignment="Start"  VerticalTextAlignment="Center" TextColor="White"></Label>
            <Image Source="search.png" HorizontalOptions="EndAndExpand" HeightRequest="25" Margin="0,2,10,2"></Image>
        </StackLayout>
    </Shell.TitleView>


    <TabbedPage.Children>
        <Views:PendingTimesheets Title="Pending" IconImageSource="icon_pending.png"/>
        <Views:ApprovedTimesheets Title="Approved" IconImageSource="icon_approved.png"/>
    </TabbedPage.Children>
</TabbedPage>

我没有添加TimesheetTab子页面的代码,因为直接导航到它时它可以正确显示。 ios出现问题的原因是什么?任何帮助表示赞赏。

0 个答案:

没有答案
相关问题