あなたはCLLocationCoordinate2D coordinate
プロパティを実装するためにあなたのTableViewDelegateクラス
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CLLocationCoordinate2D coordinate = ... // Obtain coordinate from selected index path
YourMapViewController * controller = ... // initialize YourMapViewController
// Your YourMapViewController class has to implement coordinate property as CLLocationCoordinate2D
controller.coordinate = coordinate;
// This is an example case you are using navigation controller, it can be modal transition as well.
[self.navigationController pushViewController:controller animated:YES];
}
あなたYourMapViewControllerクラスが持っている中で、したがって、たとえばMKMapView
// You specify lat,lng as coordinate and the map centers around it
- (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated
// You specify a region (center lat,lng and span) and the map centers and zooms appropriately
- (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
中のいずれかの方法を使用することができます。また、viewDidLoadではmapView
のsenterCoordinate...
メソッドを呼び出してマップを中央に配置する必要があります。
- (void) viewDidLoad {
[super viewDidLoad];
...
[mapView setCenterCoordinate:self.coordinate animated:NO];
}
私はその位置を表示できますか? マップを表示するためのコードは次のものです。 - (void)viewDidLoad { [super viewDidLoad]; mapView = [[MKMapView alloc] initWithFrame:self.view.bounds]; mapView.mapType = MKMapTypeStandard; CLLocationCoordinate2D coord = {緯度:37.183843、経度:-3.689346}; //これは、行を選択すると自動的に取得したいものです。 MKCoordinateSpan span = {latitudeDelta:50、longitudeDelta:50}; MKCoordinateRegion region = {coord、span}; [mapView setRegion:region animated:TRUE]; mapView.frame = self.view.frame; } –
私はそれを行うことができません...私のコードを見れば気になりますか? –
大麦、コードを電子メールで送信できますか? –