简体   繁体   English

在导航控制器中添加标签栏控制器时隐藏后退按钮

[英]hide back button when tab bar controller is added in navigation controller

I have a navigation controller (navC) and I have a view controller (ViewC) which is a view pushed from root controller. 我有一个导航控制器(navC),我有一个视图控制器(ViewC),它是从根控制器推送的视图。 I have hidden back button for ViewC with code: 我为ViewC隐藏了后退按钮,代码如下:

[[self navigationItem] setHidesBackButton:YES];

I have pushed tab bar controller (tabbarC) after ViewC . 我在ViewC之后推了标签栏控制器(tabbarC)。 In the view controller associated with the first tab in tabbarC I have tried hiding the back button with the code: 在与tabbarC中的第一个选项卡关联的视图控制器中,我尝试使用代码隐藏后退按钮:

 [[[self tabBarController] navigationItem] setHidesBackButton:YES];

But the back button is still visible When i click it; 但是当我点击它时,后退按钮仍然可见; it disappears... can any one help me hiding the back button for all the views in the tabbarC. 它消失了...任何人都可以帮我隐藏tabbarC中所有视图的后退按钮。

In your first view that will appear when you push to your tabbarviewcontroller set this 在您推送到tabbarviewcontroller时出现的第一个视图中设置此项

-(void)viewWillAppear:(BOOL)animated{
      [super viewWillAppear:animated];
      self.tabBarController.navigationItem.hidesBackButton=YES;
}

In viewDidLoad of ViewC do this: 在ViewC的viewDidLoad中执行此操作:

[self.navigationController.navigationItem setHidesBackButton:YES];

Also tab selected view controller's viewWillAppear method 还可以选中选项卡视图控制器的viewWillAppear方法

[self.navigationController.navigationItem setHidesBackButton:YES];

In your view just write this line..it will hide back button .. tested 在你的视图中只需写下这一行..它将隐藏后退按钮.. 测试

-(void)viewWillAppear:(BOOL)animated
{
    [self.navigationItem setHidesBackButton:YES];
}

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

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