带按钮的Ios Map注释

时间:2014-10-19 21:01:19

标签: ios objective-c mapkit

我有viewforAnnotation的定义:

        - (MKPinAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id        <MKAnnotation>)annotation{

    MKPinAnnotationView *view = nil;
    //MKPinAnnotationView *view=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"HotSpotsLoc"];

    if(annotation !=mapView.userLocation){
        view = (MKPinAnnotationView *)
        [mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"];
        if(nil == view) {
            view = [[MKPinAnnotationView alloc]
                     initWithAnnotation:annotation reuseIdentifier:@"identifier"];
        }



        UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeSystem];
        [btnViewVenue setTitle:@"Foo" forState:UIControlStateNormal];
        view.rightCalloutAccessoryView=btnViewVenue;
        view.enabled = YES;
        view.pinColor = MKPinAnnotationColorPurple;
        view.canShowCallout = YES;
        view.multipleTouchEnabled = NO;
        //view.animatesDrop = YES;

    }       
    return view;
}

它通常有效,添加按钮等。但是当我补充说:

 [btnViewVenue setTitle:@"Foo" forState:UIControlStateNormal];

要设置按钮的标题,程序不再起作用,我无法添加任何注释或任何东西,只需要mapview。谁能告诉我有什么问题? 感谢。

1 个答案:

答案 0 :(得分:0)

更改此

UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeSystem];

UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeCustom];