2

カスタム placeMark で MKMapView を使用しています。これには NSString 値があり、mkannotationview 画像にラベルとして追加したいと思います。

- (MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(MyPlaceMark *)annotation{

static NSString* AnnotationIdentifier = @"AnnotationIdentifier";

MKAnnotationView* MyView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];

MyView.canShowCallout=YES;
MyView.image = [UIImage imageNamed:@"MyImage.png"];
return MyView;}

画像にラベルを追加しようとしましたが、CGRect に問題があり、何も得られませんでした。

ありがとう!

4

1 に答える 1

4

注釈ビューは画像を描画しますか? その場合、UILabel をサブビューとして追加します。

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
[yourView addSubview:label];
[label release];
于 2011-05-30T11:30:56.247 に答える