MKMapViewメソッドsetSelectedを呼び出すと、アノテーションでアニメーションが動作しません。しかし、別の注釈で次回に呼び出すと、作業が始まります。MKMapView setSelected:アニメーション:初めて動作しません。
誰かが間違っている可能性のあるアイデアはありますか? おかげ
コード(2つの関連する方法):
- (void)viewDidLoad {
[super viewDidLoad];
annotations = [[NSMutableArray arrayWithCapacity:30] retain];
for (NSDictionary *entry in entries) {
double lat = [[entry objectForKey:@"lat"] doubleValue];
double lon = [[entry objectForKey:@"lon"] doubleValue];
NSString *PLZ = [entry objectForKey:@"PLZ"];
NSString *name = [NSString stringWithFormat:@"%@%@", PLZ.length != 0? [NSString stringWithFormat:@"%@, ", PLZ] : @"", [entry objectForKey:@"Ort"]];
NSString *address = [NSString stringWithFormat:@"%@ - %@", [entry objectForKey:@"Grund"], [entry objectForKey:@"Zeit"]];
CLLocationCoordinate2D coordinate;
coordinate.latitude = lat;
coordinate.longitude = lon;
MyLocation *annotation = [[[MyLocation alloc] initWithName:name address:address coordinate:coordinate] autorelease];
[mapView addAnnotation:annotation];
[annotations addObject:annotation];
}
NSLog(@"LOaded");
[self zoomToFitMapAnnotations];
}
- (void)showAnnotation:(int)i {
if (i <= [annotations count]) {
[mapView setSelectedAnnotations:[NSArray arrayWithObject:[annotations objectAtIndex:i]]];
}
}
最後の方法は、showAnnotationが呼び出されると、注釈が表示されているものです。もう一度、最初に呼び出すアノテーションでは機能しません。どんなに何度も電話しています。しかし、私が注釈を変更すると、最初に呼び出された注釈があっても作業が開始されます(意味があることを望みます)。
また、これも初めての作品:[mapView setSelectedAnnotations:[NSArray arrayWithObject:[annotations objectAtIndex:i]]];
setSelected:animated:任意のmapViewデリゲート内から呼び出すことができますか? – samfisher
あなたのコードを入れて...どこが間違っているのかわかりますか? –
質問を確認してください。関連するコードを貼り付けた – 0xSina