UISearchBar显示SearchBarInNavigationBar [英] UISearchBar displaysSearchBarInNavigationBar
本文介绍了UISearchBar显示SearchBarInNavigationBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想复制搜索栏滑入导航栏的Twitter应用程序的功能。
I want to replicate the functionality of the Twitter app where the search bar slides in to the navigation bar.
但是我遇到了问题。如果我不添加
However i have run into a problem. If i don't add
[self.searchDisplayController setDisplaysSearchBarInNavigationBar:YES];
进入viewDidLoad栏不会出现。当我点击它时,我在右侧导航项目中有一个搜索按钮,我调用上面的方法。有什么我可以做的,以确保搜索栏被绘制
into viewDidLoad the bar will not appear. I have a search button in the righthand navigation item when i click it i call the above method. Is there anything i can do to ensure the search bar gets drawn
谢谢
Jonathan
推荐答案
您可以在导航栏上添加搜索栏....
You can add search bar on navigation bar....
viewDidLoad: -
initially in your viewDidLoad:-
mySearchBar.frame = CGRectMake(0.0, -80.0, 320.0, 44.0);
[self.navigationController.navigationBar addSubview:mySearchBar];
mySearchBar.frame = CGRectMake(0.0, 0, 320, 44);
在viewWillDisappear中
in viewWillDisappear
[mySearchBar removeFromSuperview];
这篇关于UISearchBar显示SearchBarInNavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文