Three20 搜索范围
我正在使用 Three20,并且标准搜索机制正在运行。
TTTableViewController* searchController = [[[TTTableViewController alloc] init] autorelease];
searchController.dataSource = [[[MyDataSource alloc] init] autorelease];
self.searchViewController = searchController;
self.tableView.tableHeaderView = _searchController.searchBar;
我想使用范围。但我在实施它时遇到了困难。通过 Three20 代码,似乎已经内置了 searchdisplaycontroller 。是否有我缺少的方法,例如
-(void)search:(NSString *)text insideScope:(NSString *)scope
如何做我从 searchdisplaycontroller 中提取范围?我尝试使用 searchdisplaycontroller 的委托方法,但数据源未填充表。
有什么想法吗?
谢谢, 豪伊
I'm using Three20 and I've got the standard search mechanism working.
TTTableViewController* searchController = [[[TTTableViewController alloc] init] autorelease];
searchController.dataSource = [[[MyDataSource alloc] init] autorelease];
self.searchViewController = searchController;
self.tableView.tableHeaderView = _searchController.searchBar;
I'd like to use a scope. but I'm having trouble implementing it. Going through the three20 code it appears the searchdisplaycontroller is already built in. Is there a method I'm missing like
-(void)search:(NSString *)text withinScope:(NSString *)scope
How do I pull the scope from the searchdisplaycontroller? I tried using the delegate methods for the searchdisplaycontroller but the datasource isn't populating the table.
Any ideas?
Thanks,
Howie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番搜索后,我得出的结论是,Three20 核心库中肯定缺少某些内容。我做了一些窥探,发现 UISearchDisplayDelegate 方法位于 TTSearchDisplayController.m 中,不幸的是,当它们将事物交给数据源时,没有合并范围。
以下是我所做的修改:
然后
并将
我将以下内容添加到 TTTableViewDataSource.h
以下内容添加到 TTTableViewDataSource.m
现在我可以创建方法 - (void)search:(NSString*)text insideScope:(NSString* )scope 在我的数据源中,当执行带有范围的搜索时,它将做出相应的响应。当我在 tableview 控制器中实例化搜索控制器时,我还启用了 pausesBeforeSearching ,以便在用户键入时执行搜索之前等待几秒钟。这很有帮助,因为我的搜索是查询服务器,而不是在用户键入时发送每个字符,而是让他们先键入几个字符更有意义。
希望这有帮助。
豪伊
After searching high and low, I came to the conclusion that something must be missing from the core Three20 library. I did a little snooping around and found that the UISearchDisplayDelegate methods are in TTSearchDisplayController.m and unfortunately don't incorporate the scope when they hand things off to the datasource.
Here are the modifications I made:
and
and
Then I added the following to TTTableViewDataSource.h
And the following to TTTableViewDataSource.m
Now I can create the method - (void)search:(NSString*)text withinScope:(NSString*)scope in my datasource and it will respond accordingly as a search with scope is performed. I also enabled pausesBeforeSearching when I instantiate the search controller in my tableview controller so that it waits a couple of seconds before performing the search as a user types. This is helpful since my search is querying a server and rather than send each character as the user types, it makes more sense to let them type a few characters first.
Hope this helps.
Howie