2013-06-20 37 views
0

我想添加一些標註附件到一些現有的代碼。 這是我詮釋的主要代碼:試圖自定義註釋針

OTNVenueAnnotation *annotation = [[OTNVenueAnnotation alloc] init]; 
annotation.coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude); 
annotation.title = [[venue objectForKey:@"name"] uppercaseString]; 
annotation.venue = venue; 

MKPinAnnotationView* customPinView = [[MKPinAnnotationView alloc] 
             initWithAnnotation:annotation]; 

UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
     [rightButton addTarget:self 
         action:@selector(showDetails:) 
       forControlEvents:UIControlEventTouchUpInside]; 
     customPinView.rightCalloutAccessoryView = rightButton; 

[self.mapView addAnnotation: annotation]; 

生成錯誤是: 爲 'MKPinAnnotationView' 不可見@interface聲明選擇 'initWithAnnotation:'

回答

0

方法名是initWithAnnotation:reuseIdentifier:

你需要在初始化時提供帶有NSString的註釋視圖作爲重用標識符參數。

MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation 
                    reuseIdentifier:@"identifier"];