iOS Learning-Location Services 2 achieving basic positioning

Source: Internet
Author: User

1 positioning, what is the main thing to do?

1 Getting location-related data

2 Getting location-related information

As a result, I thought of playing counter-strike inside with the sight of the sights of the feeling:


2 that ... How to position it?
1 First, you have to aim.
    Locationmanager=[[cllocationmanager Alloc]init]; Define the Locationmanage object to  open the sight mirror     locationmanager.delegate=self;                  Realize the agent  own shooting    [Locationmanager requestalwaysauthorization];   Request permanent authorization  How long can you take your gun?    locationmanager.desiredaccuracy=kcllocationaccuracybest;  Set positioning accuracy  adjustment surface quasi-mirror near    //authorization authorized, approved        locationmanager.distancefilter=1000.0f;                   Set the minimum distance to get Mobile information  How far do I need to adjust?
Here's an explanation: there are two scenarios for requesting authorization: 1 Requestalwaysauthorization obtaining a permanent license 2 Requestwheninuseauthorization when using the authorization
There are six options for setting the accuracy:

1 Kcllocationaccuracybestfornavigation navigation with the highest precision, general vehicle navigation (need external power)

2 kcllocationaccuracybest; Highest accuracy when battery is used

3 kcllocationaccuracynearesttenmeters; Accurate to 10 meters

4 kcllocationaccuracyhundredmeters; Accurate to 100 meters

5 Kcllocationaccuracykilometer; accurate to 1000 m

6 kcllocationaccuracythreekilometers; Accurate to 3-kilometer

2 You're going to load the bullets, you're done with the bullets.
-(void) Viewdidappear: (BOOL) animated{     [locationmanager startupdatinglocation];//Start update location information bullets loaded}-(void) Viewdiddisappear: (BOOL) animated{    [Locationmanager stopupdatinglocation];//  End Update location information unload the bullet}
3 and then you can shoot. (Implementing a Delegate method)
/* Method of---------------------------Locationmanagerdelegate----------------------------------*/// :-() Location Manager: Location where the administrator has updated: A location information-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (nsarray *) locations{    cllocation *currentlocation=[locations lastobject];    Longtitudetextfield.text=[nsstring stringwithformat:@ "%3.5f", currentLocation.coordinate.longitude];    Latitudetextfield.text=[nsstring stringwithformat:@ "%3.5f", currentLocation.coordinate.latitude];    Hightextfield.text=[nsstring stringwithformat:@ "%3.5f", Currentlocation.altitude];}

4 in the event of a missed shot? (Protocol method)
Call failed//:-() Location Manager: An error message that an administrator has failed: An error message-(void) Locationmanager: (Cllocationmanager *) Manager Didfailwitherror: ( Nserror *) error{    //Small translation: Deny Deny    if (error.code==kclerrordenied)    {        NSLog (@ "Access Denied");    } else if (Error.code==kclerrorlocationunknown)    {        NSLog (@ "Location information Unknown");}    }


3 but will you be able to fix it? (Be careful not to let others)
1 To add two keys to the info.list!
nslocationalwaysusagedescription
nslocationwheninuseusagedescription
2 Remember right-click the option below

3 What about the effect? (Set options appear inside)

4 Running Results

5 Source Code
https://git.oschina.net/zhengaoxing/location1selflocation


iOS Learning-Location Services 2 achieving basic 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.