Xamarin.forms 如何在iOS中更新徽章计数?
我正在使用Xamarin表单中的Xamarin.forms 如何在iOS中更新徽章计数?,xamarin.forms,xamarin.ios,badge,Xamarin.forms,Xamarin.ios,Badge,我正在使用Xamarin表单中的TabbedPage。在iOS中,我无法更新选项卡页徽章项目值。我正在为iOS使用自定义渲染器。我的代码是: [assembly: ExportRenderer(typeof(TabbedPage), typeof(BottomTabbedPage))] namespace Graysons.iOS.Renderers { public class BottomTabbedPage : TabbedRenderer { public
TabbedPage
。在iOS中,我无法更新选项卡页
徽章项目值。我正在为iOS使用自定义渲染器。我的代码是:
[assembly: ExportRenderer(typeof(TabbedPage), typeof(BottomTabbedPage))]
namespace Graysons.iOS.Renderers
{
public class BottomTabbedPage : TabbedRenderer
{
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
TabBar.UnselectedItemTintColor = UIColor.FromRGB(208, 208, 208);
TabBar.BackgroundColor = UIColor.White;
TabBar.Items[1].BadgeValue = "1";
TabBar.Items[2].BadgeValue = "1";
}
}
}
应用程序初始化时,首次显示徽章值。但问题是,当我的应用程序从后台模式打开时(即按下Home按钮并重新打开应用程序),我想更新徽章值。此外,在前台模式下,我希望更新此值。如何实现这一点?我认为您应该将BadgeValue作为属性添加到选项卡页面中。 然后,您应该能够使用以下工具将其拔出:
if(Element is MyTabbedPage myTabbedPage)
{
TabBar.Items[1].BadgeValue = myTabbedPage.YourProperty;
}
您显示的代码的值始终为“1”。这是您正在使用的代码,还是您正在执行其他操作?(这将帮助我理解您可能遇到的问题。)实际上,我正在使用Xamarin的设置插件和其中存储的通知计数值,并绑定该值。如何将属性添加到TabbedPage中?