setNavigationBarHidden:YES 不适用于 searchDisplayController
我使用以下代码在详细视图控制器(我的第二个视图)中隐藏我的导航栏, 当我从 MasterViewController(我的第一个视图)中点击任何对象时,它工作得非常好。
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
但是,当我使用 searchDisplayController 过滤 masterViewController 中的表列表时 并点击结果中的任何对象,detailView 中的导航栏不会被隐藏...
如果我使用 searchDisplayController,我是否需要做任何额外的工作来隐藏导航栏?
对于调试,我在 setNavigationBarHidden:YES 行上设置断点,即使 我通过搜索结果转到detailViewController,应用程序上线了..
I'm using the following code to hide my navigationBar in the detailViewController(my second view),
and it works perfectly fine when I tap any of my object from the MasterViewController(my first view).
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:animated];
}
However, when I filter the table list in the masterViewController using searchDisplayController
and tap any object from the result, the navigationBar in the detailView doesn't get hidden...
Do I have to do any extra work to hide the navigationBar if I use the searchDisplayController?
for Debug, I set the break point on the line of setNavigationBarHidden:YES, and even if
I go to the detailViewController via search result, the application hits the line..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你应该把 [self.navigationController setNavigationBarHidden:YES];在 viewWillLayoutSubviews 函数中。像这样:
它有效。
you shuold put [self.navigationController setNavigationBarHidden:YES]; in viewWillLayoutSubviews function.like this:
it works.
你应该尝试这个方法:
在该控制器中,您声明了
UISearchController *searchController
,您应该实现两个方法(仅作为示例):上面的代码可能有所不同。
hidesNavigationBarDuringPresentation
属性中的要点(iOS 8.0 及更高版本)。尝试使用它,并在推送新控制器之前转向hidesNavigationBarDuringPresentation = NO
。经过这些操作后,我获利了:当推送 UIViewController 时,设置器setNavigationBarHidden:YES
开始工作You should try this method:
In that controller, where you declared
UISearchController *searchController
, you should implement two methods (only for example):The code above may have differences. Main point in
hidesNavigationBarDuringPresentation
property (iOS 8.0 and later). Try to play with it, and turn tohidesNavigationBarDuringPresentation = NO
before pushing a new controller. After this manipulations I took profit: when pushed UIViewController, settersetNavigationBarHidden:YES
become working如果您想隐藏导航栏,请在主窗口 xib 中取消选中导航控制器的“显示导航栏”属性。
这将隐藏整个项目中的导航栏。如果您想在任何控制器中显示导航栏,请在该控制器的 ViewDidLoad 方法中设置 NavigationBar Hidden = NO。
if you want to hide Navigation bar then, In your MainWindow xib uncheck "Shows Navigation Bar" attributes of Navigation Controller.
This Will hide the Navigation Bar in your Whole Project. If you want to Show Navigation Bar in any Controller set NavigationBar Hidden = NO in ViewDidLoad Method of that Controller.
您应该以某种方式破解搜索显示控制器以隐藏其内置导航栏。
这是答案:
https://stackoverflow.com/a/6337037/1348121
you should hack search display controller in some way to hide its built in navigationBar.
here is the answer:
https://stackoverflow.com/a/6337037/1348121
这
会导致布局问题,所以我使用了下面的代码。对我来说效果很好。
This
causes layout problems, so i used code below. Works fine for me.