UISearchBar代替UINavigationController UINavigationBar [英] UISearchBar in place of UINavigationController UINavigationBar
问题描述
我有一个 UITableViewController
与 UISearchDisplayController
(和 UISearchBar
),它包含在 UINavigationController
中作为根元素。是否可以配置它,使 UISearchBar
出现 UINavigationBar
?我不认为隐藏导航栏将工作,下一个屏幕(推送)要求它是可见的(这将创建一个奇怪的动画毛刺)。
I have a UITableViewController
with a UISearchDisplayController
(and UISearchBar
) that is contained in a UINavigationController
as the root element. Is it possible to configure it so the UISearchBar
appears in place of the UINavigationBar
? I don't think hiding the navigation bar will work, a the next screen (pushed on) requires it to be visible (and this will create a strange animation glitch).
我基本上打算像 App Store 搜索标签。
I'm basically going for a screen like the App Store search tab.
我已上传了其现在的样子截图:
I've uploaded a sample screenshots of how it looks now:
推荐答案
将自己分配为UINavigationController的委托并实现 - (void)navigationController: (UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
。
Assign yourself as the delegate of the UINavigationController and implement - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
.
然后使用传入的navigationController隐藏导航栏。
[navigationController setNavigationBarHidden:YES animated:animated]
Then use the passed in navigationController to hide the navigation bar.
[navigationController setNavigationBarHidden:YES animated:animated]
来想一想,最好将动画值传递给 -setNavigationBarHidden:animated:
。代码已更新。
这篇关于UISearchBar代替UINavigationController UINavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!