Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hiding title of navigationbar

my first view named "back". I need to hidden the title of the navigationbar because I have my custom navigation bar.

I try with this code but it didn't work!

self.title = @"back";
self.navigationController.navigationItem.titleView.hidden = YES;
like image 384
Dany Avatar asked Jul 06 '11 19:07

Dany


4 Answers

Just faced the same issue, and doing:

self.title = @"YourTitle";
self.navigationItem.titleView = [[UIView alloc] init];

Did the trick. The next view will have the back button labeled with YourTitle but in the first one, the title won't be shown.

like image 159
Thecafremo Avatar answered Oct 08 '22 07:10

Thecafremo


If you want to hide entire navigation bar and if you want to use your own navigation bar, you can first hide navigation controller's navigation bar.

[self.navigationController setNavigationBarHidden:YES];

or if you want to only hide title you can do

self.title = @"";

or if you have used custom title view for navigation bar, you can do

self.navigationItem.titleView.hidden = YES;

or if you want to hide back bar button item, you can do

self.navigationItem.hidesBackButton = TRUE;
like image 31
iMOBDEV Avatar answered Oct 08 '22 07:10

iMOBDEV


Having the same issue, I just create a fake UIView to populate the titleView property and hide it :

UIView *fakeTitleView = [[UIView alloc] init];
fakeTitleView.hidden = YES;
[self.navigationItem setTitleView:fakeTitleView];
[fakeTitleView release];

Hope it could help.

like image 24
olaurendeau Avatar answered Oct 08 '22 05:10

olaurendeau


Another option which preserves the back button:

[self.navigationController.navigationBar setTitleTextAttributes:@{
    NSForegroundColorAttributeName : [UIColor clearColor]
}];
like image 26
José Manuel Sánchez Avatar answered Oct 08 '22 07:10

José Manuel Sánchez