android 百度地图 在线建议查询,iOS:有没有做过"UISearchBar+百度地图在线建议查询"搜索地名的功能的?...

有没有做过"UISearchBar+百度地图在线建议查询"搜索地名的功能的?

我用 UISearchBar + 百度地图在线建议查询 第一次搜索无结果, 以后搜索的都是上一次的结果, 求大神指点该怎么做?

部分代码如下:

- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {

// 发送内容进行搜索

BMKSuggestionSearchOption* option = [[BMKSuggestionSearchOption alloc] init];

option.keyword = searchString;

[self.searcher suggestionSearch:option];

//刷新表格

return YES;

}

//实现Delegate处理回调结果

- (void)onGetSuggestionResult:(BMKSuggestionSearch*)searcher result:(BMKSuggestionResult*)result errorCode:(BMKSearchErrorCode)error{

if (error == BMK_SEARCH_NO_ERROR) {

self.keyListArray = result.keyList;

self.cityListArray = result.cityList;

self.districtListArray = result.districtList;

}

else {

NSLog(@"抱歉,未找到结果");

}

}

#pragma mark - UITableview相关

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 1;

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

if (tableView == self.searchDisplayController.searchResultsTableView) {

return [self.keyListArray count];

}else{

return 0;

}

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *flag=@"cellFlag";

UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:flag];

if (cell==nil) {

cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag];

}

if (tableView==self.searchDisplayController.searchResultsTableView) {

[cell.textLabel setText:self.keyListArray[indexPath.row]];

}

// else{

// [cell.textLabel setText:self.dataList[indexPath.row]];

// }

return cell;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值