Linux world
Linux world

Reputation: 3768

how can i add buttons to my navigation controller toolbar,so that i can see them in all views

I AM HAVING nav controller and in main view.nib i added two buttons on to tool bar and i should view these in next views also,but iam not able to see right now those in next view , where i hav to add these so i can see these buttons or access in any view ....

any help appreciated...

Upvotes: 0

Views: 756

Answers (2)

Gurpartap Singh
Gurpartap Singh

Reputation: 2764

Quick and easy way is to set the toolbar items for new view controller, before you push it.

// Assuming self.toolbarItems is already set.
UIViewController *newViewController = [[[UIViewController alloc] init] autorelease];

[newViewController setToolbarItems:self.toolbarItems];

[self.navigationController newViewController animated:YES];

If you're finding applying this method before each pushing tedious, then you can subclass all your UIViewController implementations, and have it's toolbar be set, once and for all. :)

Upvotes: 3

Sharjeel Aziz
Sharjeel Aziz

Reputation: 8535

You would need to set the toolbarItems property of each view.

When displayed, this toolbar obtains its current set of items from the toolbarItems property of the active view controller. When the active view controller changes, the navigation controller updates the toolbar items to match the new view controller, animating the new items into position when appropriate.

http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

Upvotes: 1

Related Questions