Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding buttons to ui navigation controller bottom bar

Tags:

iphone

I am able to unhide the navigation controller bottom bar by using the following code

[self.navigationController setToolbarHidden:NO];

But now I want to change the color of the bottom bar and also add buttons to that bottom bar. Can any one please help me how to do that is there any delegate methods for that?

like image 616
user564963 Avatar asked Feb 23 '11 05:02

user564963


People also ask

How do I add a button to my navigation bar?

Example ExplainedUse any element to open the dropdown menu, e.g. a <button>, <a> or <p> element. Use a container element (like <div>) to create the dropdown menu and add the dropdown links inside it. Wrap a <div> element around the button and the <div> to position the dropdown menu correctly with CSS.

How do you customize navigation buttons?

6. To customize quick shortcut on the left side of the navigation bar, scroll down and tap on “Type”, below “Extra left button”. Here, you can choose any shortcut you want. It will be assigned to the left side of the navbar.


1 Answers

In the viewDidLoad method of each view controller that you are displaying within the navigation controller, add code such as the following:

//set up the toolbar
[self.navigationController setToolbarHidden:NO];
[self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];  //for example

//set the toolbar buttons
 [self setToolbarItems:[NSArray arrayWithObjects:button1, button2, nil]];  

In this case, button1 and button2 are IBOutlet properties of the view controller, with the actual buttons defined as UIBarButtonItem within IB (but not part of the view hierarchy within IB).

Alternatively you can use code to create the buttons - like this:

UIBarButtonItem* button1 = [[[UIBarButtonItem alloc] initWithTitle:@"Button Text" style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)] autorelease];
like image 137
Appliziner Avatar answered Sep 28 '22 22:09

Appliziner