我在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)