2

enter image description here

I am IOS Developer. I am using navigation controller. If I push to next page then Back button title always Show "Back". I try all this method for remove titles in viewWillAppear, viewDidload like below. But it is not working for me.

[[UIBarButtonItem alloc] initWithTitle:@""
                                     style:UIBarButtonItemStylePlain
                                    target:nil action:nil];

or

[self.navigationItem.backBarButtonItem setTitle:@""];

or

self.navigationItem.title=@"";

or

 self.navigationController.navigationBar.backItem.title =@"";

Thanks in advance.

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
Bhumesh Purohit
  • 491
  • 1
  • 8
  • 26

4 Answers4

5

Swift 4:

navigationItem.backBarButtonItem = UIBarButtonItem()

You can also do it in Storyboard, select your View Controller's Navigation Item, and set it's Back Button property to " " (one spacebar character).

Both ways should be done on the View Controller you're segueing from.

enter image description here

Nikola Milicevic
  • 2,886
  • 3
  • 17
  • 17
3

Just try this,

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) 
                                                     forBarMetrics:UIBarMetricsDefault];

or use like this,

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

or use like this,

- (void)layoutSubviews{
    self.backItem.title = @"";
    [super layoutSubviews];
}

Swift

UIBarButtonItem.appearance().UIOffsetMake(0, -60)

or use like

self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: self.navigationItem.backBarButtonItem.style, target: nil, action: nil)

For additional information, Please see [this].(UINavigationBar Hide back Button Text)

Community
  • 1
  • 1
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
1

I think you only need to add an custom image for back button like this:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_back"]
                                                               style:UIBarButtonItemStylePlain
                                                              target:self
                                                              action:@selector(invokeButtonBack:)];

self.navigationItem.leftBarButtonItem = backButton;


with header_back is your custom image for back button.
If you using a custom base viewcontroller (maybe tableviewcontroller) simplify creat a function like this:

- (void)createBackButton{
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_back"]
                                                                   style:UIBarButtonItemStylePlain
                                                                  target:self
                                                                  action:@selector(invokeButtonBack:)];

    self.navigationItem.leftBarButtonItem = backButton;
}

Then call it in your viewcontroller with: [self createBackButton];
Hope my answer will help you.

Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
Bad_Developer
  • 537
  • 5
  • 20
0

You need to add following line in ViewDidLoad.

 self.navigationController.navigationBar.topItem.title = @"";
KKRocks
  • 8,222
  • 1
  • 18
  • 84
azamatikus
  • 73
  • 6