首页 > iOS:"百度地图+搜索栏"搜索地名的时候显示上一次搜索的内容,第一次不显示,是不是线程的问题?如何解决?

iOS:"百度地图+搜索栏"搜索地名的时候显示上一次搜索的内容,第一次不显示,是不是线程的问题?如何解决?

代码如下:

// 搜索栏相关代理方法
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString {
    // 发送内容进行搜索
    BMKSuggestionSearchOption* option = [[BMKSuggestionSearchOption alloc] init];
    option.keyword  = searchString;
    BOOL flag =  [self.searcher suggestionSearch:option];

    if (flag) {
        // 设置数据
        if (BMKResult != nil) {
            self.keyListArray = BMKResult.keyList;
            self.cityListArray = BMKResult.cityList;
            self.districtListArray = BMKResult.districtList;
        }
    }
    
    
    //刷新表格
    return YES;
}

static BMKSuggestionResult *BMKResult = nil;

//百度地图实现Delegate处理回调结果
- (void)onGetSuggestionResult:(BMKSuggestionSearch*)searcher result:(BMKSuggestionResult*)result errorCode:(BMKSearchErrorCode)error{
    if (error == BMK_SEARCH_NO_ERROR) {
        NSLog(@"%@", BMKResult);
        
        BMKResult = result;

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

小弟需要做搜索地名功能,对百度地图也不是太熟悉,利用"百度地图+搜索栏"搜索地名的时候显示上一次搜索的内容,第一次不显示,代码在上面,求大神给解决一下?非常感谢

【热门文章】
【热门文章】