简体   繁体   English

隐藏导航控制器后退按钮iOS 7

[英]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. 我试图通过在我的viewDidLoad方法中添加以下行来隐藏导航控制器中的后退按钮。 Many other previous answers on SO have said this works, so I don't know what my problem is? 关于SO的许多其他先前的答案都说这有效,所以我不知道我的问题是什么? Maybe something new with iOS 7 / Xcode 5? 也许是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 . 仅当您未自定义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. 请检查您是否在iOS 7 “返回”,然后上述操作将起作用。

Hope this will help you to identify the issue 希望这能帮助您找出问题所在

In UINavigationController we can hide Like this: UINavigationController我们可以隐藏像这样:

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

And In UITabBarController we can Hide Like this: UITabBarController我们可以隐藏如下:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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