Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone iOS:MapKit:如何设置搜索请求获取的注释数_Iphone_Ios_Objective C_Mapkit - Fatal编程技术网

Iphone iOS:MapKit:如何设置搜索请求获取的注释数

Iphone iOS:MapKit:如何设置搜索请求获取的注释数,iphone,ios,objective-c,mapkit,Iphone,Ios,Objective C,Mapkit,我有以下代码用于在我的应用程序中检索餐馆 NSLog(@"getting restaurants"); MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init]; request.naturalLanguageQuery = @"restaurant"; request.region = self.mapView.region; MKLocalSearch *localSearch = [[MKLocalSearch

我有以下代码用于在我的应用程序中检索餐馆

NSLog(@"getting restaurants");
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = @"restaurant";
request.region = self.mapView.region;

MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {

    NSMutableArray *annotations = [NSMutableArray array];

    [response.mapItems enumerateObjectsUsingBlock:^(MKMapItem *item, NSUInteger idx, BOOL *stop) {
        MapViewAnnotation *annotation = [[MapViewAnnotation alloc] initWithPlacemark:item.placemark];

        annotation.title = item.name;
        annotation.coordinate = item.placemark.location.coordinate;
        //annotation.subtitle = item.placemark.addressDictionary[kABPersonAddressStreetKey];
        //annotation.phone = item.phoneNumber;

        [annotations addObject:annotation];
    }];

    [self.mapView addAnnotations:annotations];
}];
如何设置要加载的批注数量限制?
现在,只加载了一手可用的点。当我进一步放大时,我再次调用代码,并显示其他点。

在向数组添加对象时,您可以设置计数器。如果大于指定的数字。停止向数组中添加。我得到的是很少的..不是很多:)