Вкладки скрывают иконки для дочерних страниц iOS TabbedRenderer - PullRequest
0 голосов
/ 22 мая 2018

Я внедряю вкладки в iOS, используя Xamarin.Forms TabbedRenderer.Но на вкладках скрываются значки после перехода на дочерние страницы.

Ниже приведен мой код

public class CustomTabRenderer_iOS : TabbedRenderer
{
  public override void ViewWillLayoutSubviews()
   {
      base.ViewWillLayoutSubviews();

      foreach (var item in TabBar.Items)
       {    
         item.Image = GetTabIcon(item.Title);                                   
       }
   }

  private UIImage GetTabIcon(string title)
  {
      UITabBarItem item = null;
      switch (title)
      {
        case "Dairy":
        item = new UITabBarItem("Dairy", UIImage.FromFile("dairy"), 0);
        break;
        case "My kid":
        item = new UITabBarItem("My kid",UIImage.FromFile("kid"),0);
        break;
        case "Events":
        item = new UITabBarItem("Events", UIImage.FromFile("events"), 0);

        break;
        case "About":
        item = new UITabBarItem("About", UIImage.FromFile("about"), 0);
        break;
      }
      var img = (item != null) ? UIImage.FromImage(item.SelectedImage.CGImage, item.SelectedImage.CurrentScale, item.SelectedImage.Orientation) : new UIImage();
      return img;
  }

}

Это страница Attendance.xaml

<?xml version="1.0" encoding="utf-8" ?>
<Shared:CToolbarPage xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="edTheSIS.Pages.Attendance"
    Title="My Kid"
    Icon="kid"
    xmlns:Shared="clr-namespace:edTheSIS.Shared;assembly=edTheSIS">
    <ContentPage.Content>
       <StackLayout>
       <Label Text="This is attendance..!"
       </StackLayout>
   </ContentPage.Content>
</Shared:CToolbarPage>

Событие нажатия кнопки «Присутствие ниже»

 private async void CreateTabs()
  {
    var tp = new MyTabbedPage();
    tp.Children.Add(new DairyTabPage());
    tp.Children.Add(new Attendance());
    tp.Children.Add(new Events());
    tp.Children.Add(new About());
    tp.CurrentPage = tp.Children[1];
    await Navigation.PushAsync(tp);
  }

Для получения дополнительной информации см. Снимок экрана ниже, где значок вкладки «Мой ребенок» не отображается

enter image description here

1 Ответ

0 голосов
/ 23 мая 2018

Вероятно, проблема, с которой я столкнулся, на дочерних страницах я не настраивал должным образом Заголовок и на основе Заголовок были только значки.В ниже метод

1006 *
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...