我曾在一個應用程序名稱時間跟蹤器上工作。用戶可以手動輕掃並通過單擊按鈕手動輕掃。根據ios中的位置登錄和註銷捕獲
現在我想使它成爲基於位置檢測的自動化。爲此,我正在使用CLLocationManager
類。它有時工作正常,有時它會給出錯誤的滑動細節。我使用下面的代碼。
- (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
}
}
}
誰能幫我對這個..