Change Button Text iPhone


 

Change Button Text iPhone

In a UINavigationController based application, most of the time you can find that the back button on TopView shows the same title as the previous view has. And it looks quite odd when the title is too long. But luckily we can change the button text in iPhone app.

In a UINavigationController based application, most of the time you can find that the back button on TopView shows the same title as the previous view has. And it looks quite odd when the title is too long. But luckily we can change the button text in iPhone app.

Change Button Text iPhone

In a UINavigationController based application, most of the time you can find that the back button on TopView shows the same title as the previous view has. And it looks quite odd when the title is too long. But luckily we can change the button text in iPhone app.

Find the given code that will change the text on the back button. You can also give it a Title of your choices instead of Back. We are calling it "Home" in our UINavigationController application.

Code:

self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"HOME"
style: UIBarButtonItemStyleBordered
target:nil
action:nil];

Just copy this code into your ViewDidLoad method and build the application. It must have the same output as given in the Image.


Download Code

Ads