tags:

views:

157

answers:

1

Hi,

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?

A: 

I am pretty sure you cannot share subviews like that across multiple views.

You will have to create three unique instances of that regView instead of sharing one instance.

St3fan
Hi, thanks but its an image which is a status indicator in my app and allows the user to know whats happening in the app regardless of what view he/she is in. So i need to update it in one place really, how do i do this
tech74