Problem moving MKPinAnnotation to iPhone card

I am creating an application that tracks the location of a user on a map. I can easily insert the pin, but when the location has changed, the application closes.

I set the default coordinates to 0.0 in the viewdidload: method and I added a pin at that location. I did this because I want to delete the contact when the location is updated, and then paste the output into a new location again.

Here is the code I wrote in - (void) locationManager: didUpdateToLocation: fromLocation: method.

 [mapview removeAnnotation:myannotation]; 
 CLLocationCoordinate2D currentlocation;
 currentlocation.latitude=newLocation.coordinate.latitude;
 currentlocation.longitude=newLocation.coordinate.longitude;

 myannotation=[[[CSMapAnnotation alloc]initWithCoordinate:currentlocation annotationType:CSMapAnnotationTypeStart title:@"My Location"] autorelease];

 [mapview addAnnotation:myannotation];  

Here myannotation is the output I want to add, newLocation is the updated location, and CSMapAnnotation will return the annotation.

, . . :

" 0x182020 CSMapAnnotation , . ".

, plz , - ...

+3
3

, :

  • MKMapView showsUserLocation, . , userLocation mapview.

  • autorelease. - myannotation retain, myannotation self.myannotation.

  • , , " 0, 0." lat/longs, , :-) . , .

+1

, autorelease myannotation, , , , , . , .

0

, - . 0,0, - -180, -180 ( , , ?)

- -180, -180 . , .

0

Source: https://habr.com/ru/post/1714772/


All Articles