2

マップにボタンがある iPhone アプリを作成しようとしていますが、どうすればよいですか? 私はすでにそれを実装MKMapViewして設定しlongitude/latitude、必要な場所に配置しました。

4

2 に答える 2

6

あなたはあなたの質問を詳しく説明していないので、あなたが望むと思います、

使用する MKUserTrackingBarButtonItem

 - (void)viewDidLoad
    {
        [super viewDidLoad];    
        MKUserTrackingBarButtonItem *buttonItem = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self.map];
        self.navigationItem.rightBarButtonItem = buttonItem;
    }

AMKUserTrackingBarButtonItemobject は、ユーザーがユーザー追跡モードを切り替えることができる特殊なバー ボタン アイテムです。たとえば、ユーザーがボタンをタップすると、マップ ビューはユーザーの追跡をヘディングありとなしで切り替えます。ボタンは、別の場所に設定されている場合、現在のユーザー追跡モードも反映します。このバー ボタン アイテムは、1 つのマップ ビューに関連付けられています。

この質問もお読みくださいIphoneでマップにボタンを配置する方法

于 2013-03-29T04:11:14.583 に答える
1

それを試してみてください....

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinAnnotation = nil;
    if(annotation != myMapView.userLocation) 
    {
        static NSString *defaultPinID = @"myPin";
        pinAnnotation.pinColor = MKPinAnnotationColorRed;
        pinAnnotation = (MKPinAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinAnnotation == nil )
            pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

        pinAnnotation.canShowCallout = YES;

        infoButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
        [infoButton setBackgroundImage:[UIImage imageNamed:@"arrow_go_map.png"] forState:UIControlStateNormal];
        pinAnnotation.rightCalloutAccessoryView = infoButton;
        [infoButton addTarget:self action:@selector(detailBtnClk:) forControlEvents:UIControlEventTouchUpInside];
    }    
    return pinAnnotation;
}

私が助けてくれることを願っています

于 2013-04-01T06:05:28.013 に答える