私のシナリオでは、私はXamarin Forms
でTabbed
ページを持って、次のとおりです。Xamarinフォームのタブ付きページの検出方法 - iOS?
public partial class MainPage : TabbedPage
{
public MainPage()
{
InitializeComponent();
var playPage = new NavigationPage(new PlayPage())
{
Title = "Play",
Icon = "play.png"
};
var settingsPage = new NavigationPage(new SettingsPage())
{
Title = "Settings",
Icon = "settings.png"
};
var favoritesPage = new NavigationPage(new FavoritesPage())
{
Title = "Favorites",
Icon = "fave.png"
};
var aboutPage = new NavigationPage(new AboutPage())
{
Title = "About",
Icon = "info.png"
};
Children.Add(playPage);
Children.Add(favoritesPage);
Children.Add(settingsPage);
Children.Add(aboutPage);
}
}
私は私のアプリに一時停止し、再生機能を追加したいです。起動時にPlayPage
は最初はplay.png
のアイコンを持ち、PlayPage
を再びクリックすると、アイコンはpause.png
に変わります。ページはページアイコンだけを変更するものではありません。誰にどのようにこれを行うことができるか考えている?
編集:私は持っている
var tabbarController = (UITabBarController)this.ViewController;
if (null != tabbarController)
{
tabbarController.ViewControllerSelected += OnTabBarReselected;
}
そして、私のOnTabBarReselected
:
private void OnTabBarReselected(object sender, UITabBarSelectionEventArgs e)
{
switch (TabBar.SelectedItem.Title)
{
case "Play":
TabBar.SelectedItem.Title = "Pause";
TabBar.SelectedItem.Image = UIImage.FromFile("pause.png");
break;
}
}
これはのみませ
は、だから私はOnElementChanged
に私はViewControllerSelected
を利用、カスタムレンダラを作成しました仕事の半分。選択したタブバーのTitle
をPlay
からPause
に変更します。これは同じタブをクリックした後で、Icon
では表示されません。アイコンは、そのタブページから出て別のタブを選択するまで、「play.png」のままです。誰でも何か考えがありますか?