简体   繁体   中英

Hide Navigation Controller Back Button iOS 7

I have tried to hide the back button in my navigation controller by adding the following lines to my viewDidLoad method. Many other previous answers on SO have said this works, so I don't know what my problem is? Maybe something new with iOS 7 / Xcode 5?

self.navigationItem.hidesBackButton = YES;
self.navigationController.navigationItem.hidesBackButton = YES;

I too had faced similar issue. This will work only when you have not customized your Navigation bar . Either one of the below one will work.

[self.navigationItem setHidesBackButton:YES animated:YES];   OR
[self.navigationItem setHidesBackButton:YES];

Please check whether your getting "Back" in iOS 7 , then the above will work.

Hope this will help you to identify the issue

In UINavigationController we can hide Like this:

[self.navigationItem setHidesBackButton:YES animated:YES];

And In UITabBarController we can Hide Like this:

self.tabBarController.navigationItem.hidesBackButton = YES;
self.navigationItem.leftBarButtonItem = 
 [[UIBarButtonItem alloc] initWithCustomView:[[UIView alloc] init]];

Use following code :

[self.navigationItem setHidesBackButton:YES animated:YES]; // hide back button

[self.navigationItem setBackBarButtonItem:nil]; // set as nil

[self.navigationItem setLeftBarButtonItem:nil animated:NO];  // left bar item as nil

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM