I’m making an app using apple’s mapkit framework. What I want to do is to get longitude and latitude from a location that you press. I get the coordinates from the users current location using this code:
- (IBAction)longpressToGetLocation:(id)sender {
CLLocationCoordinate2D location = [[[self.mapView userLocation] location] coordinate];
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);
}
How do I get that code to show the pressed location instead of userlocation?
First of all, use a
UIGestureRecognizerinstead anIBActionSwift 2:
Swift 3: