views:

84

answers:

2

Hi,

As mentioned in the title, how do I implement such a functionality?

I am using the code below, (in my viewDidLoad), to get the button on my Navigation Controller of my main view.

UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];

[infoButton addTarget:self action:@selector(viewWillAppear:) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];

Not sure how I can get it displayed in all my views. Thanks in Advance !

~Susanth

A: 

Each view pushed to the navigation stack has an own navigation bar. So I afraid you have to add this button to each navigation bar, when you create a view and before you push this view to the navigation stack.

OgreSwamp
The `UINavigationController` uses only one `UINavigationBar`, but every `UIViewController` on the stack has their own `UINavigationItem`, in which the title and the bar button items are defined.
Douwe Maan
Sorry, yes, that what I mean. Thanks for correction.
OgreSwamp
A: 

You could simply add an info button to the window, instead of creating a new button for each view controller. Since the window never changes, the button will always be on screen. You only have to take care that no other views are on top of the button.

Nikolai Ruhe
Hi, Ruhe. Thanks for your post.I had tried what you had said. However, I couldn't get it to work. My Window calls (via code in the delegate file) a view which uses a Tab Bar. Any idea why it doesn't work?
Susanth