Change text on back button in iPhone SDK - iphone

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];

Related

iOS how to set FBFriendPickerViewController doneButton's title

there is a "doneButton" and a "cancelButton" in FBFriendPickerViewController, whose default title is "Done" and "Cancel". I want to customize the title:
FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.title = #"invite your friend";
friendPickerController.doneButton.title = #"invite";
I think it should work, but it didn't. the title of doneButton was still "Done".
how can i set it? thanks!
This is how you change the title on the Done and Cancel buttons in a FBFriendPickerViewController:
friendPickerController.cancelButton = [[UIBarButtonItem alloc] initWithTitle:#"Skip it!" style:UIBarButtonItemStyleBordered target:self action:nil];
friendPickerController.doneButton = [[UIBarButtonItem alloc] initWithTitle:#"Invite!" style:UIBarButtonItemStyleDone target:self action:nil];

How to make navigation button with Login and Setting title

I want to add two buttons two navigation bar on right hand side one for settings and one for login but problem is that only one button i have searched comes on right that is edit is there any other way in which we can make two button and give them desired title.
UIBarButtonItem *addAttachButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(addAttachmentClicked:)];
UIBarButtonItem *sendButton = [[UIBarButtonItem alloc] initWithTitle:LS(#"Send") style:UIBarButtonItemStyleBordered target:self action:#selector(sendClicked:)];
self.navigationItem.rightBarButtonItems = #[addAttachButton,sendButton];
Here is the code I am using in My UIViewController's implementation file (.m file)
-(void)viewDidLoad{
[super viewDidLoad];
//back button
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:#" Back " style:UIBarButtonItemStyleBordered target:self action:#selector(backTo:)];
//Optional: if you want to add space between the back & login buttons
UIBarButtonItem *fixedSpaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedSpaceBarButtonItem.width = 12;
//login button
UIBarButtonItem *signIn_BarButton = [[UIBarButtonItem alloc]initWithTitle:#" SIGN IN " style:UIBarButtonItemStyleBordered target:self action:#selector(signInUser)];
//add all buttons to right side
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:backButton, fixedSpaceBarButtonItem,signIn_BarButton, nil];
}
now here are the metthods for both button clicks
-(IBAction)backTo:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
-(void) signInUser{
//handle your sigin logic here
}
Please! let me if you need more help!

Back in UINavigationItem making problem

i have problem that i have 3 views,
i goto first view to 2nd and want to change mine back button title
i write this code in viewDidLoad of 2nd View but its not working :(
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithTitle:#"Back" style:UIBarButtonItemStyleDone target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backButton];
go to 1st view controller and add the following code before you push the viewController,
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:#"Inv Menu" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];

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];

How to use an icon as back button for UINaviationController

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