2009-11-19 27 views

回答

1

您需要創建CLLocationManger對象並調用startUpdatingLocation方法。一旦找到並更新位置,CLLocationMangerDelegate方法

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation 

將自動調用。您可以重新實現此方法並從此處調用Web服務。

3

在你有MKMapView本身顯示用戶所在位置的情況下(以編程爲「mapView.showsUserLocation = YES;」或IB檢查「顯示用戶位置」),然後在地圖視圖將調用viewForAnnotation當引腳被丟棄。您可以使用:

- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    if ([annotation isKindOfClass:MKUserLocation.class]) { 
    // Call web service here 
    return nil; 
    } 
} 

返回nil告訴地圖視圖使用其默認引腳用戶位置(藍色圓點動畫)。 不要忘記將您的控制器設置爲MKMapViewDelegate