The 'Tag' property of a UITabBarItem sounds like a useful thing, but in practice, how does one use it? According to the documentation:
- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag Parameters
title
The item's title. If
nil
, a title is not displayed.image
The item's image. If
nil
, an image is not displayed.The images displayed on the tab bar are derived from this image. If this image is too large to fit on the tab bar, it is scaled to fit. The size of an tab bar image is typically 30 x 30 points. The alpha values in the source image are used to create the unselected and selected images—opaque values are ignored.
tag
The receiver's tag, an integer that you can use to identify bar item objects in your application.
But the only code I have found to retrieve a UITabBarItem by its tag is something similar to the following:
for (UIViewController *viewController in stTabBarController.viewControllers) {
if (viewController.tabBarItem.tag == MyTabBarItemTag) {
// do stuff
}
}
I can make this as a category function, but it seems like I'm missing something. Surely something like this is already implemented? Or am I just missing the point of the tag attribute?