views:

298

answers:

1

I have a navigation based application that have a uinavigataioncontroller containing uitableviewcontrollers. I want to add buttons to the UINavigationbar of the uinavigataioncontroller, usually I write code to add these buttons, something like this:

UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveClicked:)]; 
self.navigationItem.rightBarButtonItem = saveButton;
[saveButton release];

My idea now was to use interface builder instead. But I'm not sure how to do it. What I'm trying to do is to add a UINavigationItem in the xib file of the viewcontroller (my viewcontroller is called TextViewController), something like this:

See this image: http://i48.tinypic.com/qq5yk7.jpg

But how can I make TextViewController use the UINavigationItem I added? The button I add doesn't show in the navigationbar.

Any ideas on how to do this? What am I missing?

A: 

You can take a bar button in the coding like IBOutlet UIBarButtonItem * saveButton;

Then you have to take a bar button in the xib file and bind this button with that and in coding you can directly write self.navigationItem.rightBarButtonItem = saveButton;

Its almost the same as your code but the only thing changes is you dont have to initialize the barbutton..

Happy coding...

Suriya
Thanks! If that was the easiest solution I think I stick with using code.
Martin