Ios CCLocationManager说我';我在伦敦
几天以来我一直有这个问题。。。无法找出原因,但此方法:Ios CCLocationManager说我';我在伦敦,ios,geolocation,cllocationmanager,Ios,Geolocation,Cllocationmanager,几天以来我一直有这个问题。。。无法找出原因,但此方法: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { long now = [[[NSDate alloc] init] timeIntervalSince1970]; //avoid cached
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
long now = [[[NSDate alloc] init] timeIntervalSince1970];
//avoid cached locations
if(abs([newLocation.timestamp timeIntervalSinceNow]) > 15.0f)
{
return;
}
//avoid more the 1KM location
if(newLocation.horizontalAccuracy > 1000 || newLocation.horizontalAccuracy < 0)
{
return;
}
//if we already located, no need to go any further
if(alreadyLocated)
{
[locationManager stopUpdatingLocation];
return;
}
alreadyLocated = YES;
[self stopLocating];
[[SPPreferenceHandler getInstance] setValue:[NSNumber numberWithLong:now] forKey:LAST_LOCATION_UPDATE];
CLLocation *currentLocation = newLocation;
if (currentLocation != nil) {
//blabla some code
}
}
-(void)locationManager:(CLLocationManager*)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation*)oldLocation
{
long now=[[NSDate alloc]init]timeIntervalSince1970];
//避免缓存位置
如果(abs([newLocation.timestamp timeIntervalSinceNow])>15.0f)
{
返回;
}
//避免超过1公里的位置
if(newLocation.HorizontalAccurance>1000 | | newLocation.HorizontalAccurance<0)
{
返回;
}
//如果我们已经找到了,就不需要再进一步了
如果(已重新定位)
{
[locationManager停止更新位置];
返回;
}
alreadyLocated=是;
[自动停止定位];
[[SPPreferenceHandler getInstance]设置值:[NSNumber numberWithLong:now]forKey:LAST_LOCATION_UPDATE];
CLLocation*currentLocation=newLocation;
如果(当前位置!=nil){
//布拉布拉一些代码
}
}
总是说我在伦敦:
正在打印当前位置的说明:
我不知道发生了什么事。。。
信息方面,我正在一台iPhone5上测试,测试时将其插入Mac并拔下。。。同样的问题依然存在
如果你们能帮我的话!那太好了 好吧,这里是为了防止像我这样的人陷入这种错误: 确保进入产品->方案->编辑,然后取消选中“允许位置模拟”