隐藏导航控制器返回按钮 iOS 7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20063703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 22:26:21  来源:igfitidea点击:

Hide Navigation Controller Back Button iOS 7

iosuinavigationcontrollerios7back-button

提问by Adam Johns

I have tried to hide the back button in my navigation controller by adding the following lines to my viewDidLoadmethod. 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?

我试图通过将以下几行添加到我的viewDidLoad方法中来隐藏导航控制器中的后退按钮。以前关于 SO 的许多其他答案都说这有效,所以我不知道我的问题是什么?也许 iOS 7 / Xcode 5 有什么新东西?

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

回答by Nattudurai

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.

我也遇到过类似的问题。这仅在您尚未自定义Navigation bar. 以下任一方法都可以使用。

[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.

请检查您是否在“返回”中iOS 7,然后上述操作将起作用。

Hope this will help you to identify the issue

希望这能帮助您确定问题

回答by Nag Raj

In UINavigationControllerwe can hide Like this:

UINavigationController我们可以像这样隐藏:

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

And In UITabBarControllerwe can Hide Like this:

而在UITabBarController我们可以隐藏就像这样:

self.tabBarController.navigationItem.hidesBackButton = YES;

回答by JPlay

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

回答by Rigel Networks

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