1

Using MonoTouch 5.4 on new XCode and iOS 6.0

Old ViewController In TabBarController code:

this.TabBarItem.BadgeValue = "5";

No longer works.

New code, changing to this does work:

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

By not work I mean the badge does not appear, the value is just ignored in the old case.

Ian Vink
  • 66,960
  • 104
  • 341
  • 555
  • ahah, the names **iOS6** and **Xcode 4.5** are disclosed / public, including most *high level* features (i.e. what you can see on Apple site without logging in). By not working you mean it's not showing the badge ? or it's throwing? e.g. `TabBarItem` being `null`. – poupou Sep 14 '12 at 18:58
  • The badge doesn't appear, seems to just swallow the setting of the value. – Ian Vink Sep 14 '12 at 19:16

1 Answers1

0

I think this is normal. Maybe your code was changed / refactored before the update ?

TabBarItem is defined in UIViewController and represent the tab bar item of this view controller.

So this.TabBarItem is the tab bar item of this this view controller, e.g. I used a UITabBarController in my code (let's call it parent).

this.TabBarController.TabBar.Items[x] would represent the tab bar item of one of the child view controller of this parent.

So when I create child1 and child2 (both instances of UIViewController) and assign them to parent.ViewControllers we get three instances of UITabBarItem (one for parent, one for each child) - but only two of them (the children will ever be visible).

E.g. from logging the handle values

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

So I can either do:

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

to get the same behaviour. However changing the parent.TabBarItem won't be visible anywhere (at least not in my case where this is the RootViewController of my test application).

poupou
  • 43,413
  • 6
  • 77
  • 174