我有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。谁能告诉我有什么问题? 感谢。
答案 0 :(得分:0)
更改此
UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeSystem];
到
UIButton *btnViewVenue = [UIButton buttonWithType:UIButtonTypeCustom];