当前位置: 代码迷 >> Iphone >> 关于MKMapView 显示自己位置的有关问题
  详细解决方案

关于MKMapView 显示自己位置的有关问题

热度:18   发布时间:2016-04-25 06:04:30.0
关于MKMapView 显示自己位置的问题

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{  
    MKCoordinateSpan theSpan;
    //地图的范围 越小越精确
    theSpan.latitudeDelta = 0.01;
    theSpan.longitudeDelta = 0.01;
    MKCoordinateRegion theRegion ;
    theRegion.center = newLocation.coordinate; 
    theRegion.span = theSpan;
    [self.mapView setRegion:theRegion animated:YES];
    
}


这样设置那个我的位置那个绿点每次都不是在地图正中间。求解。 

------解决方案--------------------
看看有没有设置delegate
------解决方案--------------------
同意一楼的,应该是委托设置的问题。
你设置了地图的委托是没错,你也是从地图上获取的经纬度。
但是,你检查是否更新经纬度的事件(didUpdateToLocation)是locationManager的,而不是MKMapView的,而locationManager的委托是否绑定在你这个类上了?
LZ该去检查一下,看看是否是我说的这个原因。