相关疑难解决方法(0)

如何在我的应用程序中获得与苹果地图相同的搜索提示

我在iOS应用程序中实现了搜索栏.我想获得与Apple Maps应用程序相同(部分结果)的搜索提示.我试图找出苹果如何实现它,但我在谷歌或在stackoverflow上没有成功.

在我的UITableView*searchHintTableView中显示的内容无关紧要.我只是没有得到正确的搜索提示数量.我在相同的设备和相同的3G wifi网络(3G SIM路由器)上使用我的应用程序和Apple Maps应用程序.

我尝试了什么:

  • 我试图用半径指定区域.
  • 从先前的请求中取消地理编码.

在方法中:

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText;
Run Code Online (Sandbox Code Playgroud)

我有以下代码:

    ...
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    NSString *location = [NSString stringWithFormat:@"%@", searchText];


//    CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:coord
//                                                               radius:100000000 identifier:@"Hint Region"];

//    [geocoder cancelGeocode];
    [geocoder geocodeAddressString:location
                 completionHandler:^(NSArray *placemarks, NSError *error) {
                     if (error != nil) {
                         DDLogCVerbose(@"Error %@", [error description]);
                         [searchHintArray removeAllObjects];
                         [searchHintTableView reloadData];
                         return;
                     }
                     DDLogCVerbose(@"CLGeocoder >> %@", [placemarks description]);
                     //to get rid of unwanted results …
Run Code Online (Sandbox Code Playgroud)

geocoding objective-c ios apple-maps

5
推荐指数
0
解决办法
417
查看次数

标签 统计

apple-maps ×1

geocoding ×1

ios ×1

objective-c ×1