所以,我創建了一個CLLocationManager,叫它開始更新,將mapView.showsUserLocation設置爲YES,並返回nil作爲userLocation註釋。 下面是我的一些代碼片段在我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 2010-08-24 01:39:28
這是一個很好的觀點。地圖視圖的userLocation最初爲零,因此最好檢查註釋的類,而不是將其與mapView.userLocation進行比較。 – spstanley 2011-01-09 16:18:38