views:

74

answers:

2

I am setting a tag for my navigationBar using:

self.navigationController.navigationBar.tag = 1;

When you select a cell and the child UITableView loads, I set:

self.navigationController.navigationBar.tag = 2;

But when I hit the 'back' button and the Parent UITableView appears again, the .tag is still set to 2.

I have tried setting tag=1 in the Parent's viewDidLoad, viewWillAppear, viewDidAppear and in the Child's viewWillDisappear - any help would be greatly appreciated.

A: 

As a rule of thumb, only use .tag properties on non-system UIView classes. You might be better off mapping these navbars in an NSMutableArray.

David Sowsy
Can you expand a bit on how to 'map these navbars in an NSMutableArray' ? The only way I've found to get my image into the navBar is to add: @implementation UINavigationBar(MyCustomBackground) - (void)drawRect:(CGRect)r { [[UIImage imageNamed:@"my-navigation-background.png"] drawInRect:self.bounds]; } @endto the .m file
Chris
A: 

hey Chris, I have the exact same issue. I want to have different images for Navbar's, i.e I have 2 tableviews, in a tabbar app. I want to have different images for navigationBar's. I have got the drawRect category code in the .m file of my tableViewController, now I don't know where to set the tag property so that different images will be loaded depending up the views.Please help