2011-01-15 12 views
0

ユーザーが現在の場所にズームインすると、脈打った青色の点と円が表示されます。しかし、それは非常にうまく表示されません。私は、コードがviewForAnnotationの場所である必要があることを理解しています。関連するコードは次のとおりです。もっと必要な場合は教えてください!円と青い点を示すためMapkit:青色の点と円を脈打つ

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

if ([annotation isKindOfClass:[MKUserLocation class]]) 
    return nil; //return nil to use default blue dot view 

//NSLog(@"View for Annotation is called"); 
MKPinAnnotationView *pin=[[MKPinAnnotationView alloc] 
          initWithAnnotation:annotation reuseIdentifier:nil]; 
pin.userInteractionEnabled=TRUE; 

[pin setPinColor:MKPinAnnotationColorGreen]; 
pin.canShowCallout = YES; 
pin.animatesDrop = YES; 

MapEvent* event = (MapEvent*)annotation; 
NSLog(@"%@",event.uniqueID); 

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
[rightButton addTarget:self action:@selector(clickAnnotation:) forControlEvents:UIControlEventTouchUpInside]; 
[rightButton setTitle:event.uniqueID forState:UIControlStateNormal]; 

pin.rightCalloutAccessoryView = rightButton; 

return pin; 

}

+0

"表示されない"とはどういう意味ですか? – donkim

答えて

4

alootおかげで、YESにMKMapViewのshowsUserLocationプロパティを設定します。

+0

ベンが正しいです。また、Core Locationからの情報に基づいてマップの中心を表示し、MKMapViewで 'showsUserLocation'をオンにした場合、シミュレータの青い点は表示されません。シミュレータは常にMapKitに指示しますあなたの現在の場所は米国カリフォルニア州クパチーノです(Appleの本部)。ただし、デバイス上で正常に動作します。 –

+0

ああ!わかった。すべてのあなたの助けをお寄せいただきありがとうございます! :D – funatsg

関連する問題