【发布时间】:2015-08-27 03:30:01
【问题描述】:
我第一次尝试使用地图视图功能。我有一个地图视图、文本字段和搜索按钮。目前一切正常:
- (IBAction)searchLocation:(id)sender {
// Create and initialize a search request object.
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = _nameLocation.text;
request.region = _mapview.region;
// Create and initialize a search object.
MKLocalSearch *search = [[MKLocalSearch alloc] initWithRequest:request];
// Start the search and display the results as annotations on the map.
[search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error)
{
NSMutableArray *placemarks = [NSMutableArray array];
for (MKMapItem *item in response.mapItems) {
[placemarks addObject:item.placemark];
}
[_mapview removeAnnotations:[_mapview annotations]];
[_mapview showAnnotations:placemarks animated:NO];
}];
}
现在我需要向 pin 添加事件处理程序。如果用户单击 pin 我想打开新控制器并将地址显示为文本。如果有人能告诉我如何让我有一个监听器,当用户单击 pin 时,它会为我执行一些功能,我将不胜感激。此外,我想访问 pin 上显示的地址。
编辑 我实际上需要知道用户何时单击图钉显示的文本。这里是“Miranda NSW” 当用户点击文本时表示他们接受了地址。
【问题讨论】:
标签: ios objective-c mapkit