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.navigation开发者_C百科Controller.navigationItem.titleView.hidden = YES;
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.
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;
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.
Another option which preserves the back button:
[self.navigationController.navigationBar setTitleTextAttributes:@{
NSForegroundColorAttributeName : [UIColor clearColor]
}];
Swift
self.navigationItem.title = "your title" // So title shows nav "back" button
self.navigationItem.titleView = UIView() // To hide the title on this View Controller
I put this in viewWillAppear
精彩评论