كيفية الحصول على الدقة المرغوبة من الموقع الأساسية في محاكاة؟

StackOverflow https://stackoverflow.com/questions/2005698

سؤال

أريد التحقق من الدقة المرغوبة في محاكاة لكنني لم أحصل عليه أبدا في طريقة DidupDateToLocation. أعرف أنه في طريقة مندوب محاكي تسمى مرة واحدة فقط. هل يعرف شخص ما يعرف كيفية الحصول على الدقة المرغوبة في محاكاة.

// 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];
        }
    }
}
هل كانت مفيدة؟

المحلول

على مدير موقع محاكي يقوم دائما بإرجاع الموقع نفسه بنفس الدقة. لذلك يجب عليك إما ضبط عتبة الدقة الخاصة بك عند استهداف محاكي أو مجرد خدمة اختبار الموقع على الجهاز الحقيقي.

#if TARGET_IPHONE_SIMULATOR
   double Accuracy = 100;
#else
  double Accuracy = 5;
#endif
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top