tags:

views:

603

answers:

2

here is my code....?how to integrate UINavigation bar with UIBarbuttonitem?

UINavigationBar *nav= [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
nav.backgroundColor = [UIColor whitecolor];
//nav.tintColor = [UIColor darkGrayColor];
[self.view addSubview:nav];
[nav release];
A: 

Try init your item and then

nav.leftBarButtonItem = barButtonItem;

or

nav.rightBarButtonItem = barButtonItem;

You can only have two items on the navigation bar

phunehehe
A: 

Note that UIBarButtonItem buttons are properties of the UINavigationItem, not the UINavigationBar.

For example, when using a UINavigationController, it automatically provides its own UINavigationBar. But each of the views managed by the navigation controller can define a UINavigationItem, which controls the title, left and right buttons, etc.

Mirko Froehlich