ios--positioning

Source: Internet
Author: User

Core Location---positioning frame

Cllocationmanager This attribute must be written as global, otherwise it will be released after initialization.

Authorized
nslocationwheninuseusagedescription : When the app is in the foreground, you can get the location information nslocationalwaysusagedescription
Control according to the actual situation.

Code that is actually authorized:
  //以此来判断,是否是ios8      if ([locationManager respondsToSelector: @selector (requestWhenInUseAuthorization)]) {          [locationManager requestWhenInUseAuthorization];      }Kclauthorizationstatusnotdetermined: The user has not been requested to obtain the authorization authorization box will only pop up once, if the customer turned off the positioning function, should pop up the prompt box.

Kclauthorizationstatusrestricted: The user has closed the location service in the settings
Kclauthorizationstatusdenied: The user received a request to obtain authorization, but clicked No, or closed in the settings
Kclauthorizationstatusauthorized: The user receives a request for authorization and clicks Yes; (this status is deprecated in iOS8, iOS7 and the following are available)
Kclauthorizationstatusauthorizedalways = kclauthorizationstatusauthorized User licensed app to get location information at any time
Kclauthorizationstatusauthorizedwheninuse: User authorized app to get location information at reception

if ([Cllocationmanager authorizationstatus]==kclauthorizationstatusdenied) {        NSLog (@ "Please open Location Services");        Nsurl *settingsurl = [Nsurl urlwithstring:uiapplicationopensettingsurlstring];        [[UIApplication sharedapplication] openurl:settingsurl];    }

  

[Self.locationmanager startupdatinglocation]; Start location service-(void) Locationmanager: (Cllocationmanager *) Manager Didupdatelocations: (Nsarray *) Locations corresponding Proxy method
[_locationmanager stopupdatinglocation];
Positioning can consume a lot of resources, so the proxy is closed.

  

Now required: Get the corresponding place name based on location-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations{    NSLog (@ "%@", locations.lastobject);    Cllocation *location=locations.lastobject;    [Self.geocoder reversegeocodelocation:location completionhandler:^ (Nsarray *placemarks, NSError *error) {       Clplacemark *placemark=placemarks.lastobject;        NSLog (@ "More info:%@", placemark.addressdictionary[@ "Formattedaddresslines"]);    }];}

  

ios--positioning

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.