그래서 CLLocationManager를 작성하여 업데이트를 시작하고 mapView.showsUserLocation을 YES로 설정하고 userLocation 주석에 대해 nil을 반환했습니다. 여기 내 UIMapViewController에 내 코드에서 일부 조각입니다 :showsUserLocation은 iPhone 4.0에서 파란색 점을 표시하지 않습니다.
- (void)viewDidLoad
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D userCoordinate = locationManager.location.coordinate;
[map setCenterCoordinate:userCoordinate animated:YES];
[map setShowsUserLocation:YES];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *mapIconView = (MKAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:@"mapIconView"];
// Don't mess with the user location annotation
if (annotation == mapView.userLocation)
return nil;
// etc.
}
이 모두 매우 간단 보인다. 모든 것이 잘 작동합니다.지도는 필연적으로 내 위치를 확대하고, 모든 메소드가 예상대로 호출되지만 파란색 점이 없음을 확인했습니다. 내 인생에 대한 푸른 점을 얻을 수 없다. 내가 몇 번이나 말을하든간에
mapView.setUserLocation = YES;
무엇이 여기에 실종되어 있습니까? 나는이 작업을 수행 할 때
감사합니다.하지만 아무 것도 바뀌지 않는 것 같습니다. 아직 점이 없습니다. 코드를 단계별로 살펴보고 {return nil; } 전화가 오면 문제가 있다고 생각하지 않습니다. – Aeonaut
이것은 매우 좋은 지적입니다. 지도보기의 userLocation은 처음에는 nil이므로 주석을 mapView.userLocation과 비교하는 대신 주석의 클래스를 확인하는 것이 좋습니다. – spstanley