1
votes

I am trying to implement a masterDetail app with hamburger menu. It works in android but crashes on iOS with "FileNotFoundException" and shows default instead the icon.

I have added an icon to iOS. Resources project but still does not show and both the master and navigation page have the icon.

Am I doing something wrong? Any workaround? thanks a lot

app.xaml

    public partial class App : PrismApplication
    {
        public App(IPlatformInitializer initializer = null) : base(initializer) { }

        protected override void OnInitialized()
        {
            try
            {
                InitializeComponent();

                NavigationService.NavigateAsync("MainMasterDetail/MyNavigationPage/MainPage",animated:false);
            }
            catch (Exception e)
            {
               Debug.WriteLine(e.ToString());
            }           
        }

        protected override void RegisterTypes()
        {
            Container.RegisterTypeForNavigation<MainMasterDetail,MainMasterDetailViewModel>();
            Container.RegisterTypeForNavigation<MyNavigationPage,MyNavigationPageViewModel>();
            Container.RegisterTypeForNavigation<MainPage>();
            Container.RegisterTypeForNavigation<ViewA,ViewAViewModel>();
            Container.RegisterTypeForNavigation<ViewB,ViewBViewModel>();

        }
    }

MainMasterDetails.xaml

        <?xml version="1.0" encoding="utf-8" ?>
        <MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                          xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                          xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
                          prism:ViewModelLocator.AutowireViewModel="True"
                          x:Class="HelloBurgerMenu.Views.MainMasterDetail"
                          Title="MainMasterDetail" Icon="humburger.png">
            <MasterDetailPage.Master>
                <ContentPage Title="Default">
                    <StackLayout>
                        <Button Text="MainPage" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/MainPage" />
                        <Button Text="ViewA" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/ViewA" />
                        <Button Text="ViewB" Command="{Binding NavigateCommand}" CommandParameter="MyNavigationPage/ViewB" />
                    </StackLayout>
                </ContentPage>
            </MasterDetailPage.Master>

        </MasterDetailPage>


MyNavigationPage

    <?xml version="1.0" encoding="utf-8" ?>
    <NavigationPage xmlns="http://xamarin.com/schemas/2014/forms"
                    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                    xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
                    prism:ViewModelLocator.AutowireViewModel="True"
                    x:Class="HelloBurgerMenu.Views.MyNavigationPage"
                    Icon="humburger.png">

    </NavigationPage>
2

2 Answers

0
votes

You can't have content in your NavigationPage. Delete all the XAML in your NavigationPage.

Look at this sample: https://github.com/xamarin/xamarin-forms-samples/tree/master/Navigation/MasterDetailPage

1
votes

Try specify the Icon in MasterPage not MasterDetail

 public MasterPage()
 {
    InitializeComponent();
    if (Device.RuntimePlatform == Device.iOS)
    {
       Icon = "menu.png";
    } 
 }