简体   繁体   English

iOS:默认“后退”按钮显示在“自定义左导航”按钮上

[英]iOS: Default Back button Being Presented Over Custom Left Nav Button

I'm getting this , once I push the view using: [self.navigationController pushViewController:viewController animated:YES]; 我发现了这个 ,一旦我推使用视图: [self.navigationController pushViewController:viewController animated:YES];

I have the code to create the left navigation button in viewWillAppear. 我有在viewWillAppear中创建左侧导航按钮的代码。 Here's my code to create the left navigation button: 这是创建左侧导航按钮的代码:

`UIButton *leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 25)];
            [leftButton setImage:[UIImage imageNamed:@"leftNavIconGray.png"] forState:UIControlStateNormal];
            [leftButton setShowsTouchWhenHighlighted:TRUE];
            [leftButton addTarget:self.navigationController.sideMenu action:@selector(toggleLeftSideMenu) forControlEvents:UIControlEventTouchDown];
            UIBarButtonItem *barBackItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
            self.navigationItem.hidesBackButton = TRUE;
            self.navigationItem.leftBarButtonItem = barBackItem;
            return;`

Notice, I do have the back button hidden in there. 请注意,我确实在其中隐藏了后退按钮。 Because the left nav button is there, viewWillAppear is being called, but for some reason the default back button being hidden is not. 由于左侧导航按钮在那里,因此将调用viewWillAppear,但是由于某种原因,默认隐藏的后退按钮没有被调用。

This only occurs when I push the view, not when I regularly load it. 仅在按下视图时才会发生这种情况,而在定期加载视图时不会发生这种情况。

Does anyone have any idea how to get that back button off of there? 有谁知道如何使该后退按钮离开那里?

I think you if your work is not done 我想你如果你的工作还没有完成

just hide the navigation bar 只是隐藏导航栏

self.navController.navigationBarHidden = YES;

and on tap of leftButton (in toggleLeftSideMenu) just pop the view controller 然后单击leftButton(在toggleLeftSideMenu中)只需弹出视图控制器

[self.navigationController popViewControllerAnimated:YES];

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

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