所以现在我至少得到回调用下面的代码...CLLocationManager startUpdatingLocation不工作
- (void)viewDidLoad {
[super viewDidLoad];
mapView=[[MKMapView alloc] initWithFrame:self.view.frame];
//mapView.showsUserLocation=TRUE;
mapView.delegate=self;
[self.view insertSubview:mapView atIndex:0];
NSLog(@"locationServicesEnabled: %@", [CLLocationManager locationServicesEnabled] ? @"YES":@"NO");
CLLocationManager *newLocationManager = [[CLLocationManager alloc] init];
[newLocationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[newLocationManager setDistanceFilter:kCLDistanceFilterNone];
[self setLocationManager:newLocationManager];
[[self locationManager] setDelegate:self];
[[self locationManager] startUpdatingLocation];
NSLog(@"Started updating Location");
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"Did update to location");
mStoreLocationButton.hidden=FALSE;
location=newLocation.coordinate;
MKCoordinateRegion region;
region.center=location;
MKCoordinateSpan span;
span.latitudeDelta=0.01;
span.longitudeDelta=0.01;
region.span=span;
[mapView setRegion:region animated:TRUE];
}
我可以在第二种方法中设置断点,并在NSLog的报告不断位置更新,但由于某些原因跨度缩放无法正常工作。任何想法为什么?它有我的坐标和一切。在我的头上划伤我的头。
乌尔代码似乎确定..问题是呃其他地方 – samfisher 2012-07-28 06:32:18
你在模拟器中遇到这些麻烦吗?你是否启用了位置模拟? – HeikoG 2012-07-28 07:29:30
是的,模拟器的麻烦。我已启用模拟位置。也许我需要在设备上测试它。 – Coltrane 2012-07-28 08:17:28