百度地图api - iOS:"百度地图+搜索栏"搜索地名的时候显示上一次搜索的内容,第一次不显示,是不是线程的问题?如何解决?
迷茫
迷茫 2017-04-17 17:45:15
[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(@"抱歉,未找到结果");
    }
}

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

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号