私は特定の郵便番号で利用可能な店舗を表示するためのアプリを開発しています。私は現在の場所から始めます。私は現在の場所に青い脈動する点を得ています。郵便番号を入力すると、マップビューに注釈を表示できます。私は現在の場所に再び戻ることができるボタン "現在の場所"を持っています。しかし、私は青い点を取得していない2回目ですか?どのように私はそれを得るか、これはコードです:マップを空に:mapview青いドットが2回目に来ない
- (void)showCurrentLocation
{
self.mapView.showsUserLocation = YES;
GPSAnnotation *annotation = [[GPSAnnotation alloc] initWithCoordinate:self.mapView.userLocation.coordinate];
annotation.title = @"Location";
[self.mapView addAnnotation:annotation];
[annotation release];
MKCoordinateRegion zoomIn;
zoomIn.center.latitude = self.mapView.userLocation.coordinate.latitude;
zoomIn.center.longitude=self.mapView.userLocation.coordinate.longitude;
zoomIn.span.latitudeDelta = .1f;
zoomIn.span.longitudeDelta =.1f;
self.mapView.showsUserLocation = YES;
[self.mapView setRegion:zoomIn animated:TRUE];
}
// annotation view
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(GPSAnnotation *)annotation
{
if ([[annotation title] isEqualToString:@"Location"])
{
MKAnnotationView *annotationView=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];
annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@"blueDot"];
annotationView.annotation = annotation;
return annotationView;
}
else if ([annotation isKindOfClass:[MKUserLocation class]])
{
return nil;
}
}
なぜGPSAnnotation座標をユーザーの位置と同じに設定していますか? viewForAnnotationメソッドは、 "制御が非void関数の終わりに達する"という警告をコンパイラに与える必要があります。少なくとも、メソッドの最後に 'return nil;'を追加して修正してください。それ以外にもいくつか問題があります。 – Anna
hi Anna Karenina、 応答ありがとうございます。私は "return nil"を追加しようとしましたが、それでも私は第2のティムのために青いドットをタトゥーしません。 – cancerian