The current location in the simulator

I am making an application in which I have to find the current location of the user. Is it possible to get the user's current location in the iOS 5 simulator using CLLocationmanager?

+6
source share
3 answers

xcode - Change the scheme - Run you.app - Option

check the box Allow location, then select "Default location"

Add GPX File to Project 

format like this

+8
source

In Xcode, you can select a location to simulate using the small button above the console.

enter image description here

+7
source
 - (void)viewDidLoad{ [super viewDidLoad]; self.title = @"MapView"; self.navigationController.navigationBarHidden = NO; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m [locationManager startUpdatingLocation]; } - (void) loadPin { iCodeBlogAnnotation *appleStore1; CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude = [latitude doubleValue]; workingCoordinate.longitude = [longitude doubleValue]; appleStore1 = [[iCodeBlogAnnotation alloc] initWithCoordinate:workingCoordinate]; [appleStore1 setTitle:[NSString stringWithFormat:@"Default Point"]]; //[appleStore1 setSubtitle:[NSString stringWithFormat:@"Distance %.2f Miles",miles]]; [appleStore1 setAnnotationType:iCodeBlogAnnotationTypeEDU]; [mapView addAnnotation:appleStore1]; [(MKMapView*)self.mapView selectAnnotation:appleStore1 animated:NO]; MKCoordinateRegion region; region.center.latitude = [latitude doubleValue]; region.center.longitude = [longitude doubleValue]; region.span.latitudeDelta = .5; region.span.longitudeDelta = .5; [mapView setRegion:region animated:YES]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { latitude = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.latitude]; longitude = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.longitude]; [locationManager stopUpdatingLocation]; if (latitude > 0) { [self loadPin]; } } 
-4
source

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


All Articles