repetedly叫我開發與定位和獲取座標成功然後我打電話web服務來存儲座標的應用程序,但是當我使用IOS 7.1設備則didupdatelocation方法不repeadly調用。這裏是我的代碼didupdatelocation不是在IOS 7.1
if ([CLLocationManager locationServicesEnabled])
{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.pausesLocationUpdatesAutomatically=NO;
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy=kCLLocationAccuracyBest;
[self.locationManager startUpdatingLocation];
}
這
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
if (UIApplication.sharedApplication.applicationState == UIApplicationStateActive)
{
CLLocationCoordinate2D center;
center.latitude = [[locations objectAtIndex:([locations count]-1)] coordinate].latitude;
center.longitude = [[locations objectAtIndex:([locations count]-1)] coordinate].longitude;
_point = [[MKPointAnnotation alloc] init];
_point.coordinate = center;
if(appDelegate.strVehicleType!=nil)
{
[self checkInternet];
}
NSLog(@"Changed");
[_locationManager stopUpdatingLocation];
}
else
{
CLLocationCoordinate2D center;
center.latitude = [[locations objectAtIndex:([locations count]-1)] coordinate].latitude;
center.longitude = [[locations objectAtIndex:([locations count]-1)] coordinate].longitude;
_point = [[MKPointAnnotation alloc] init];
_point.coordinate = center;
if(appDelegate.strVehicleType!=nil)
{
[self checkInternet];
}
NSLog(@"Location Changed in Background")
;
[_locationManager stopUpdatingLocation];
}
}
我在上面的代碼repetedly在IOS 6和iOS 7試過位置更新,但不是在7.1更新,所以請任何人都知道那裏是問題?或者是他們使用任何不同的方法。
Thanx提前。
查看我的iOS 7及以上版本解決方案。 http://stackoverflow.com/questions/18946881/background-location-services-not-working-in-ios-7/21966662#21966662有一篇博文和Github的完整解決方案。 – Ricky