Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tag for UITabBarItem

When I use the this method to initialize a UITabBarItem:

- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag

Do I need to have a distinct tag for each tab bar item, or (since I don't use them) can I simply use the same tag value for all of them?

like image 401
Sophie Alpert Avatar asked Oct 16 '25 01:10

Sophie Alpert


2 Answers

I'm pretty sure you can just leave them all as 0 or any other number you choose. Every UIView can potentially have a different tag, and Interface Builder sets them all to 0 by default. I haven't run into any problems with this.

like image 179
pix0r Avatar answered Oct 19 '25 12:10

pix0r


From Apple's UITabBarItem class reference:

tag - The receiver’s tag, an integer that you can use to identify bar item objects in your application.

So it looks like it doesn't really matter.

like image 23
Tobias Svensson Avatar answered Oct 19 '25 14:10

Tobias Svensson