私はマップビューコントローラ(UIViewController、MKMapView)をデリゲート(HCIResultMapViewController)とともに使用しています。mkannotationのカスタムデータ変数
この部分には次の機能があります。
1)。私は等のタイトル、サブタイトルなどの基本的なエンティティと一緒に他の人の詳細を関連付けることができるように私は、私のカスタムは、NSObjectのを作っ使いたい
はは、そこで自分のニーズに応じて、私は
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_houseList = [[_resultList objectForKey:@"result"] objectForKey:@"listings"];
// NSLog([_houseList description]);
int i = 0;
for (NSDictionary *house in _houseList) {
HCIAnnotationViewController *annotation = [[HCIAnnotationViewController alloc]
initwithHouse:house];
[_mapView addAnnotation:annotation];
// NSLog(@"asdjhasdjsajdhaksdjghasdasdjahsdahskvdka");
self.currIdentifier = i;
i++;
}
[_mapView setShowsUserLocation:NO];
}
HCIResultMapViewController
で
を次のようにコーディング
他のデリゲート機能
-(void) mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
for (NSObject<MKAnnotation> *annotation in _mapView.selectedAnnotations) {
NSLog(@"hellomaster");
NSLog(annotation.title);
if ([annotation isKindOfClass:[HCIAnnotationViewController class]]) {
NSLog(@"hellomaster");
}
}
最後の1
-(MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
NSString *identifier = @"currIdentifier";
MKPinAnnotationView *annotationView =
(MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.tag = self.currIdentifier;
// Create a UIButton object to add on the
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[annotationView setRightCalloutAccessoryView:rightButton];
/*
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
[leftButton setTitle:annotation.title forState:UIControlStateNormal];
[annotationView setLeftCalloutAccessoryView:leftButton];
*/
return annotationView;
}
しかし、私はクラスの等価性が失敗することがわかります。私が間違っていることを教えてくれますか?
単純な言葉で言いますと、必要なときにいつでも取得できるように、データ(NSDictionary *)とアノテーションを一緒に送信するにはどうすればいいですか?
この質問には繰り返し質問があります。私はグーグルなど多くの質問を試みましたが、これに適した解決策を見つけることができませんでした。
あなたはカスタムアノテーションを作成したいと思います。タイトル、サブタイトルのようなものですか? – iPatel
番号。私の注釈には、タイトル、サブタイトルのようなエンティティとともにNSDictionary *が含まれています。 –