【问题标题】:MonoTouch: TabItem BadgeValueMonoTouch:TabItem BadgeValue
【发布时间】:2012-09-07 22:59:19
【问题描述】:

在新的XCodeiOS 6.0 上使用MonoTouch 5.4

ViewController In TabBarController 代码:

this.TabBarItem.BadgeValue = "5";

不再有效。

新代码,改成这样就行了:

this.TabBarController.TabBar.Items[theIndexOfTab].BadgeValue = "5";

不工作是指徽章没有出现,在旧情况下该值被忽略。

【问题讨论】:

  • 啊哈,iOS6Xcode 4.5 的名称已公开/公开,包括大多数 高级 功能(即什么无需登录即可在 Apple 网站上查看)。不工作是指它没有显示徽章?还是在扔?例如TabBarItemnull
  • 徽章没有出现,似乎只是吞下了值的设置。

标签: ios xamarin.ios uitabbarcontroller badge


【解决方案1】:

我认为这很正常。也许您的代码在更新之前已更改/重构?

TabBarItemUIViewController中定义,代表this视图控制器的tab bar item

所以this.TabBarItem 是这个 this 视图控制器的标签栏项目,例如我在代码中使用了UITabBarController(我们称之为parent)。

this.TabBarController.TabBar.Items[x] 将代表 this parentchild 视图控制器之一的 tab bar item

因此,当我创建 child1child2UIViewController 的两个实例)并将它们分配给 parent.ViewControllers 时,我们得到了三个 UITabBarItem 实例(一个用于父母,一个用于每个孩子) - 但只有其中两个(孩子们将永远可见)。

例如从记录句柄值

2012-09-14 20:13:24.092 test1[47917:1507] parent.TabBarItem.Handle = 291086496
2012-09-14 20:13:24.094 test1[47917:1507] parent.TabBar.Items [0].Handle = 218412640
2012-09-14 20:13:24.094 test1[47917:1507] parent.TabBar.Items [1].Handle = 160885040
2012-09-14 20:13:24.095 test1[47917:1507] child1.TabBarItem.Handle = 218412640 
2012-09-14 20:13:24.096 test1[47917:1507] child2.TabBarItem.Handle = 160885040

所以我可以这样做:

child1.TabBarItem.BadgeValue = "5"; // or
parent.TabBar.Items[0].BadValue = "5";

获得相同的行为。但是,更改 parent.TabBarItem 将不会在任何地方可见(至少在我的情况下,这是我的测试应用程序的 RootViewController)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-16
    • 2011-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多