タイトルにあるように、ボタンを押して、自分のアプリ内から ios デバイスでネイティブ マップ アプリを開きたいと考えています。現在MKmapview
、ファイルから取得した緯度/経度の単純なピンを表示するを使用していjson
ます。
コードはこれです:
- (void)viewDidLoad {
[super viewDidLoad];
}
// We are delegate for map view
self.mapView.delegate = self;
// Set title
self.title = self.location.title;
// set texts...
self.placeLabel.text = self.location.place;
self.telephoneLabel.text = self.location.telephone;
self.urlLabel.text = self.location.url;
**// Make a map annotation for a pin from the longitude/latitude points
MapAnnotation *mapPoint = [[MapAnnotation alloc] init];
mapPoint.coordinate = CLLocationCoordinate2DMake([self.location.latitude doubleValue], [self.location.longitude doubleValue]);
mapPoint.title = self.location.title;**
// Add it to the map view
[self.mapView addAnnotation:mapPoint];
// Zoom to a region around the pin
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(mapPoint.coordinate, 500, 500);
[self.mapView setRegion:region];
}`
ピンに触れると、タイトルと情報ボタンを含む情報ボックスが表示されます。
これはコードです:
#pragma mark - MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
MKPinAnnotationView *view = nil;
static NSString *reuseIdentifier = @"MapAnnotation";
// Return a MKPinAnnotationView with a simple accessory button
view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseIdentifier];
if(!view) {
view = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
view.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
view.canShowCallout = YES;
view.animatesDrop = YES;
}
return view;
}
上の情報ボックスのボタンをクリックすると、現在のユーザーの場所から上の mapPoint への道順でマップ アプリを開くメソッドを作成したいと考えています。それは可能ですか?また、このボタンの外観をカスタマイズできますか? (つまり、ボタンに別の画像を配置して、「ちょっと方向を押して」のように見せます)。
ばかげた質問で申し訳ありませんが、これは私の最初の iOS アプリであり、Obj-c は私にとってまったく新しい言語です。
事前にすべての返信をありがとう。