0
ボタンを注釈ビューに追加し、そのボタンにアクションを割り当てたいとします。私のコードには小さな問題があるだけです。今detailButtonをMKAnnotationViewに追加
// so when I touch the pin , and the annotation view is displayed , I create a button and add it to the view
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
view.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
}
// when the button is pressed , go to another view
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"calloutAccessoryControlTapped");
ArticleViewController *det = [[ArticleViewController alloc]init];
det.leTitle = view.annotation.title;
det.link = @"http://en.wikipedia.org/wiki/San_Francisco";
[self.navigationController pushViewController:det animated:YES];
}
、問題が
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
機能が動作しない 、私が触れて初めて注釈とボタンが作成されていることです。注釈を選択解除してもう一度触れると、正しく機能します。あなたは私のコードをimpove助けることができますか?ありがとう。
問題が解決した場合は、お答えください。 –