zeigt aktuelle Position, zusammen mit einem anderen Ort in iphone

stimmen
2

wenn wir eine mapview laden, es automaticallay zeigt den aktuellen Standort des Nutzers richtig. In meinem Fall zeige ich einen anderen Ort auf der Karte, so dass die Karte den aktuellen Standort lädt und gezoomt auf den Standort i gegeben haben .. aber wurde die aktuelle Position Punkt nicht angezeigt (die blaue, die automaticay kommt ..). Ich habe mapView.showCurrentLocation = TRUE gegeben; aber es ist nicht zeigt. so könnte jemand sagt, wie es funktioniert, und es sollte die aktuelle Position Marke sagen und dann auf den Punkt gezoomt i gegeben haben. Vielen Dank

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
    static NSString *defaultPinID = @CameraAnnotation;
    MKPinAnnotationView *retval = nil;
    static int postag=1;

    (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
    if(annotation=MapView.userLocation)
    {
        return nil;
    }
    // If we have to, create a new view
    else    if (retval == nil)
    {
        retval = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];

        UIButton *myDetailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        myDetailButton.frame = CGRectMake(0, 0, 50, 23);
        myDetailButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        myDetailButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        myDetailButton.tag=postag;
        postag++;
        [myDetailButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
        retval.rightCalloutAccessoryView = myDetailButton;
        [retval setPinColor:MKPinAnnotationColorRed];
        retval.animatesDrop = YES;
        retval.canShowCallout = YES;
    }

    return retval;
}
Veröffentlicht am 07/05/2010 um 09:54
quelle vom benutzer
In anderen Sprachen...                            


2 antworten

stimmen
2

Im Simulator ist der Standard aktuelle Standort Cupertino.This ist, was Sie sehen, wird es richtig in Gerät arbeiten.

Mehr über Sie CLLocationManager verwenden sollten, den aktuellen Standort zu erhalten.

- (void)applicationDidFinishLaunching:(UIApplication *)application { 
{
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self; // Tells the location manager to send updates to this object
[locationManager startUpdatingLocation];
}

Um die Stiftfarbe zu ändern

MKPinAnnotationView   *pin=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"]autorelease];

[pin setPinColor:MKPinAnnotationColorRed];

Alles Gute.

Beantwortet am 07/05/2010 um 10:03
quelle vom benutzer

stimmen
1

werfen Sie einen Blick auf die Antwort auf diese Frage die MKMapView Zoomstufe setzen alle MKAnnotations daran befestigt umfassen

Beantwortet am 07/05/2010 um 12:38
quelle vom benutzer

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more