我曾在一个应用程序名称时间跟踪器上工作过。用户可以通过单击按钮手动滑入和手动滑出。
现在我想根据位置检测将其设为自动。为此,我正在使用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
}
}
}
谁可以帮我这个事..