1
我已经设置当前位置不在图形页面显示出来(IOS)
self.mapView.showsUserLocation = YES;
但是,我仍然无法在Map中看到当前的引脚。
我错过了什么?
这里的viewDidLoad中
- (void)viewDidLoad {
self.mapView.delegate = self;
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
#ifdef __IPHONE_8_0
if(IS_OS_8_OR_LATER) {
[self.locationManager requestAlwaysAuthorization];
}
#endif
[self.locationManager startUpdatingLocation];
self.mapView.showsUserLocation = YES;
[self.mapView setMapType:MKMapTypeStandard];
[self.mapView setZoomEnabled:YES];
[self.mapView setScrollEnabled:YES];
MKCoordinateRegion region;
region.center.latitude = 25.03;
region.center.longitude = 121.5;
region.span.latitudeDelta = 0.2;
region.span.longitudeDelta = 0.2;
[self.mapView setRegion:region animated:YES];
}
而且MapView的
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation*)userLocation
{
double X= userLocation.coordinate.latitude;
double Y= userLocation.coordinate.longitude;
NSLog(@"%f,%f",X,Y);
CLLocationCoordinate2D currentPosition = [userLocation coordinate];
MKCoordinateRegion region =MKCoordinateRegionMakeWithDistance(currentPosition, 800, 800);
[self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
}
谢谢!
您是否要求用户使用该位置的权限? –
你的意思是一个询问是否允许访问的报警窗口? –
请看这个问题的答案(http://stackoverflow.com/questions/24062509/location-services-not-working-in-ios-8),也许你会找到答案。 –