J'ai travaillé sur un tracker de temps de nom d'application. L'utilisateur peut manuellement glisser et glisser manuellement en cliquant sur le bouton.Se connecter et se déconnecter de la capture en fonction de l'emplacement dans ios
Maintenant, je voudrais le rendre aussi automatique basé sur la détection de l'emplacement. Pour cela, j'utilise la classe CLLocationManager
. Cela fonctionne parfois bien et parfois il donne de mauvais détails de balayage. J'utilise le code ci-dessous.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
[locationManager requestWhenInUseAuthorization];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
_latitude.text = [NSString stringWithFormat:@"Latitude: %f", newLocation.coordinate.latitude];
_longitude.text = [NSString stringWithFormat:@"Longitude: %f", newLocation.coordinate.longitude];
if([_latitude.text doubleValue] > 17.76890) && [_longitude.text doubleValue] > 78.34567) {
if (isSwipeIn) {
isSwipeIn = false;
//necessary swipe out UI and logic
} else {
isSwipeIn = true;
//necessary swipe in UI and logic
}
}
}
Quelqu'un peut-il me aider sur ce ..