[英]Can I have two UISearchBar in one ViewController?
Can I have two UISearchbar
in one ViewController
? 我可以在一个
ViewController
有两个UISearchbar
吗?
Basically I have a map view and I want to put a source and destination UISearchBar
on top. 基本上,我有一个地图视图,我想将源和目标
UISearchBar
放在顶部。
Now if I add two UIISearchBar and thus two UISearchDisplayControllers
, how do I determine which search bar it is in use in the delegate functions ? 现在,如果我添加两个UIISearchBar并因此添加两个
UISearchDisplayControllers
,如何确定委托函数中正在使用哪个搜索栏?
I was planning to use just one UISearchBar
which will take source first and then destination, but now the plan is to show 2 search bars. 我打算只使用一个
UISearchBar
,它将首先获取源,然后获取目的地,但是现在计划显示2个搜索栏。
I got everything working with one search bar. 我可以使用一个搜索栏进行所有操作。
You will have to store both UISearchBars in an IBOutlet like 您将必须将两个UISearchBars存储在IBOutlet中,例如
@property (nonatomic, weak) IBOutlet UISearchBar *firstSearchBar;
@property (nonatomic, weak) IBOutlet UISearchBar *secondSearchBar;
Then in your delegates do 然后在您的代表中
- (void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar
{
if (searchBar == self.firstSearchBar) {
// Do something
} else {
// Do something else
}
}
This approach can also be used when you have to deal with more than one UIAlertView, UITableView, UICollectionView etc. 当您必须处理多个UIAlertView,UITableView,UICollectionView等时,也可以使用这种方法。
我想我想通了...我必须创建uisearchdisplaycontrollers的属性,然后我可以引用searchtableview等来找出正在使用的uisearchbar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.