0
我使用此代碼來創建我的自定義註釋視圖。MKAnnotationView
- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinAnnotation = nil;
if(annotation != myMapView.userLocation) {
static NSString *defaultPinID = @"myPin";
pinAnnotation = (MKPinAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if (pinAnnotation == nil)
pinAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID];
pinAnnotation.canShowCallout = YES;
//instatiate a detail-disclosure button and set it to appear on right side of annotation
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self
action:@selector(showRestaurantDescription)
forControlEvents:UIControlEventTouchUpInside];
pinAnnotation.rightCalloutAccessoryView = infoButton;
}
return pinAnnotation;
}
我的問題是如何發送參數到我的選擇:-showRestaurantDescription:
當我想到我可以添加標籤按鈕,處理它,但我需要選擇最好的方法,因爲我有與我的餐廳陣列,當我點擊具體的針我需要顯示當前的餐廳。所以在這種情況下,標籤不是很方便,因爲我認爲。