How to use an icon as back button for UINaviationController - iphone

Does anyone know how to use an icon instead of text for the UINavigationController back button?
alt text http://www.img-hosting.de/bilder/24505iPhoneSimulator2png

Try this:
UIBarItem *backBar = [[UIBarButtonItem alloc] initWithImage:yourImage style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.backBarButtonItem = backBar;
[backBar release];
you can also use initWithCustomView if you need something more elaborate

Related

How to add image(s) to UIToolBar?

I'd like to add an image to a UIToolBar that a user cannot interact with. It would essentially be just a non-interactive indicator, like a badge.
Is this possible?
If so, how?
Create an UIBarButtonItem with an Image and add it:
Example:
UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithImage:yourImage style:UIBarButtonItemStyleBordered target:nil action:nil];
If you don't want the button appearance, try to use:
UIBarButtonItem* item = [UIBarButtonItem initWithCustomView:yourImageView];

UIBarButtonItem with no border

How can I create an UIBarButtonItem without any border, but just a label inside?
EDIT
I tried something like this with no luck:
UIBarButtonItem* langButton = [[UIBarButtonItem alloc] initWithTitle:#"EN"
style:UIBarButtonItemStylePlain target:self action:#selector(changeLang)];
self.navigationItem.leftBarButtonItem = langButton;
[langButton release];
Do the same as the following guy:
https://stackoverflow.com/a/6817554/59198
But change it so instead of an image button, you'll make a standard textual button.

need help about add navigationItem

As you see in the images, the top picture is created automatically when navigation controller is pushed
If I try to create one like this it will appear like the bottom picture.
How can I programmatically create a Back Button like the top picture?
Here is my code to create the Done button
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(backtohome)];
UIBarButtonItem *theBackButton = [[UIBarButtonItem alloc] initWithTitle:#"Done"
style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.backBarButtonItem = theBackButton;
[theBackButton release];

Change text on back button in iPhone SDK

I'm using iPhone SDK 3.1.3 and I tried look like that
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
It's not working and nothing effect. So, I tired
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
button text it change and stye it squre. I click it and it's not go to back.
I want to change back button to text #"Back". How to write it ?
I also read in there but not work for me.
I got it. I change in title and it's OK
self.navigationItem.title =#"Back";
[self.navigationController pushViewController:browser animated:YES];

How to change back button from text to image in UINavigationBar

UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
initWithImage:#"rGoBack"
style:UIBarButtonItemStylePlain
target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
I use this source. but It doesn't work. I don't know why not. please..
From the first glance:
initWithImage:#"rGoBack"
here UIImage parameter required and NSString is passed instead. Try writing something like:
initWithImage:[UIImage imageNamed:#"rGoBack.png"]; // or whatever image name you have