당신은 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; } –
음 나는 그것을 할 수 없다 ... 내 코드를 살펴 본다면 괜찮습니까? –
보리, 코드를 이메일로 보내 주시겠습니까? –