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)