iPhone SDK: How to get the selected tabitem on a tabbar? -
I have this code - (zero) tabbar: (UITabBar *) tabber selected: (UITabBarItem *) item
What I see is a code snippet that indicates how the button was pressed inside the representative.
So maybe I have 1-4 button buttons standing on the tabbar. My user presses the button position 2. I have to know that I can bring the appropriate view for that button.
I tried to do something like that but it is not working.
NSInteger * barIndex = [[barbed item] IndexofObject: item];
If a good working example can provide a code.
Thanks in advance.
When you create your UITabBarItem
s, you assign them specific tags Would like to. When your - (zero) tabbar: (UITabBar *) Tabber selected: (UITabBarItem *) item called the
method, read the tag number.
NSInteger tag = item.tag;
The index of the object is not suitable for the tab bar, as the user can change the order of tabs.
And good practice is to use an enumeration for each of your tags, so that you do not have a bunch of "random" numbers scattered in your code.
typdef enum {JPButton1, JPButton2, JPButton2} JPButtonType
and then in your tab: rebellion: didSelectItem:
You can test the tags like this:
if (item.tag == JPButton1) {// some stuff here with a button here}
Comments
Post a Comment