The Way to Programming
The Way to Programming
For a school assignment I had the idea to make an app that allows you to save a specific location where you parked your car. Now it’ll be pretty basic. You simply load the application, pinpoint a specific location on the map and that location gets saved and displayed the next time you open the app.
Now I know how to get the current location, but that’s not specifically what I wish for.
Please note that we’ve only had very, very minor information on Objective C. Perhaps helping me on how to store that location could be nice aswell.
Assuming you are using Apple’s MapKit, this should server your purpose.
- (void)viewDidLoad { UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(foundTap:)]; tapRecognizer.numberOfTapsRequired = 1; tapRecognizer.numberOfTouchesRequired = 1; [self.myMapView addGestureRecognizer:tapRecognizer]; } -(IBAction)foundTap:(UITapGestureRecognizer *)recognizer { CGPoint point = [recognizer locationInView:self.myMapView]; CLLocationCoordinate2D tapPoint = [self.myMapView convertPoint:point toCoordinateFromView:self.view]; MKPointAnnotation *point1 = [[MKPointAnnotation alloc] init]; point1.coordinate = tapPoint; [self.myMapView addAnnotation:point1]; }
Sign in to your account