IOS learning-positioning service 2 basic positioning
1. What is positioning mainly?
1. Obtain location-related data
2. Obtain Location Information
As a result, I thought of the sight targeted by the Anti-Terrorism elites:
2 ...... How to locate it?
1 first, you have to aim at it.
LocationManager = [[CLLocationManager alloc] init]; // defines the locationManage object to open the sight locationManager. delegate = self; // implement the proxy's own gun [locationManager requestAlwaysAuthorization]; // how long does it take to request permanent authorization for a gun? LocationManager. desiredAccuracy = kCLLocationAccuracyBest; // sets the positioning precision to adjust the distance of the plane to the near mirror. // authorization is adopted to approve the locationManager. distanceFilter = 1000.0f; // set the minimum distance between the obtained mobile information and the target. Do I need to adjust it?
Here, we will explain that there are two types of requests for authorization: 1 requestAlwaysAuthorization obtaining permanent authorization 2 requestWhenInUseAuthorization authorizing when using
There are six options for setting precision:
1 kCLLocationAccuracyBestForNavigation the highest precision navigation, generally used for Vehicle Navigation (external power supply required)
2 kCLLocationAccuracyBest; the highest precision for battery use
3 kCLLocationAccuracyNearestTenMeters; precise to 10 meters
4 kCLLocationAccuracyHundredMeters; accurate to 100 meters
5 kCLLocationAccuracyKilometer; precise to 1000 meters
6 kCLLocationAccuracyThreeKilometers; accurate to 3 km
2. You want to load the bullet. Should you unload the bullet after it is finished?
-(Void) viewDidAppear :( BOOL) animated {[locationManager startUpdatingLocation]; // start to update the location information bullet loading}-(void) viewDidDisappear :( BOOL) animated {[locationManager stopUpdatingLocation]; // stop updating location information to unload bullets}
3. You can take a gun next (how to implement delegation)
/* --------------------------- Method of locationmanagerdelegate ---------------------------------- * // Note:-() Location administrator: location information updated by a location administrator: Location Information-(void) locationManager :( CLLocationManager *) manager didUpdateLocations :( NSArray *) locations {CLLocation * currentLocation = [locations lastObject]; longtitudeTextField. text = [NSString stringWithFormat: @ % 3.5f, currentLocation. coordinate. longpolling]; latitudeTextField. text = [NSString stringWithFormat: @ % 3.5f, currentLocation. coordinate. latitude]; highTextField. text = [NSString stringWithFormat: @ % 3.5f, currentLocation. altitude];}
4. What if I try again? (Protocol method)
// Call failed // translate:-() Location administrator: error message indicating an administrator has failed: an error message-(void) locationManager :( CLLocationManager *) manager didFailWithError :( NSError *) error {// explanation: deny rejects if (error. code = kCLErrorDenied) {NSLog (@ access denied);} else if (error. code = kCLErrorLocationUnknown) {NSLog (@ unknown location information );}}
3. But can you decide this? (Be careful not to let others)
1. Add two keys to info. list.
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription
2. Right-click and select the following options.
3. What is the effect? (Options appear in the settings)
4. Running result