0

My Doubt is How to hide Navigation Bar title "BACK" from backbutton (but need to show backbutton Arrow.)

Thank You.

  • Try like this self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; – Bhupat Bheda Apr 27 '17 at 12:15
  • `UINavigationController` already does this for you automatically. You just need to change the `title` property of the **previous** view controller. Say you have `vcA` and `vcB` view controllers and you push from `vcA` to `vcB`. The `UINavigationBarItem` with the back button will, in `vcB`, take the title from `vcA` and show it. So if you set an empty string as the title of `vcA` before pushing, the back button in `vcB` will show an empty string too. – Alejandro Iván Apr 27 '17 at 15:24

2 Answers2

1

Use this:

YourViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"YourViewController"];
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
[self.navigationController pushViewController:viewController animated:YES];
Sargis
  • 1,196
  • 1
  • 18
  • 31
0

I suggest you use code like below :

- (void)configureNavigationBarButtonItem
{

UIButton *cancel = [UIButton buttonWithType:UIButtonTypeCustom];
[cancel setFrame:CGRectMake(0, 0, 50, 50)];

[cancel setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[cancel.titleLabel setFont:[UIFont fontWithName:@"Verdana" size:13.0f]];
cancel.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
[cancel addTarget:self action:@selector(goBack:) forControlEvents:UIControlEventTouchUpInside];
cancel.tag=3200;

imgBack = [[UIImageView alloc]initWithFrame:CGRectMake(5, 15, 18, 18)];
imgBack.image = [UIImage imageNamed:@"back_black"];
[cancel addSubview:imgBack];


UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithCustomView:cancel];
self.navigationItem.leftBarButtonItem = cancelBtn;

}
- (void)goBack:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}