wie gewünschte Genauigkeit von Kern Lage im Simulator zu bekommen?
-
18-09-2019 - |
Frage
Ich mag die gewünschte Genauigkeit in Simulator überprüfen, aber ich es nie bekommen innerhalb didupdatetolocation method.I weiß, dass in Simulator Delegatmethode nur once.Does jemand genannt wird, weiß, wie man in simulator.Here gewünschte Genauigkeit zu bekommen, ist mein Code zu erhalten gewünschte Genauigkeit.
// Delegate method from the CLLocationManagerDelegate protocol.
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSTimeInterval locationAge = -[newLocation.timestamp timeIntervalSinceNow];
if (locationAge > 5.0)
{
self.DeviceOldLocation=newLocation;
return;
}
LatitudeData = [[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.latitude] retain]autorelease];
LongitudeData =[[[[NSString alloc] initWithFormat:@"%f",newLocation.coordinate.longitude] retain]autorelease];
if (newLocation.horizontalAccuracy < 0)
return;
if (bestEffortAtLocation == nil || bestEffortAtLocation.horizontalAccuracy < newLocation.horizontalAccuracy)
{
// store the location as the "best effort"
self.bestEffortAtLocation = newLocation;
[self insertNewLocationInDataBase];
if (newLocation.horizontalAccuracy <= Accuracy)
{
self.VeryAccuratelocation=newLocation;
BestLocationAcquired=YES;
[self insertNewLocationInDataBase];
[self stopUpdatingLocation];
UIAlertView *BestLocation=[[UIAlertView alloc] initWithTitle:@"Best Location" message:@"best location found" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[BestLocation show];
[BestLocation release];
}
}
}
Lösung
Ein Simulator-Aufnahmeleiter liefert immer die gleiche Position mit der gleichen Genauigkeit. So sollten Sie entweder passen Sie Ihre Genauigkeit Schwellen, wenn Simulator Targeting oder Testort Service auf reales Gerät.
#if TARGET_IPHONE_SIMULATOR
double Accuracy = 100;
#else
double Accuracy = 5;
#endif
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow