I’m using iphone sdk 3.1.2.
I have 3 root view controllers each on separate tabs. Their left nav bar button has a custom view assigned as follows in each of their viewDidLoad methods. The master custom view is held by the AppDelegate. Each regView is a retained property. In the appDidFinishlaunching method I alloc an imageView (instance of AppDelegate) and assign it an image:
UImageView* regView;
@property (nonatomic,retain) UIImageView* regView;
-(void) viewDidLoad
{
....
self.regView = appDelegate.regView;
UIBarButtonItem* regButton = [[UIBarButtonItem alloc] initWithCustomView:self.regView];
self.navigationItem.leftBarButtonItem = regButton;
[regButton release];
}
However when I swap between the tab bar items the previous selected view controller loses its leftBarButton custom view until only the very last selected holds onto it.The other 2 can never get their leftbutton custom view back!
Anyone know what I’m doing wrong?
I am pretty sure you cannot share subviews like that across multiple views.
You will have to create three unique instances of that
regViewinstead of sharing one instance.