"CortesViewController"라는 ViewController가 있으며 MymapView 호출 된 mymap이 있습니다. CortesViewController.h에 정의되어 있고 해당 .m 파일에 구현 된 함수 showAddress가 있습니다.다른 ViewController 클래스에서 함수 호출하기
- (void) showAddress:(float) lat :(float) lon :(int) keytype
{
centerCoordinate.latitude = lat;
centerCoordinate.longitude = lon ;
NSLog(@"with key = 0, lat lon are %f, %f", centerCoordinate.latitude, centerCoordinate.longitude);
[mymap setCenterCoordinate:centerCoordinate animated:TRUE] ;
}
나는 이름과 위도 및 경도와 장소의 목록을 포함하고 CortesViewController에 배치 버튼을 앞으로 가져 수있는 다른있는 UITableViewController "PlacesViewController"가. 어떤 장소의 이름을 클릭하면지도의 중심에서 선택된 장소를 표시하는 mymap으로 돌아가고 싶습니다. 그래서 "showAddress"함수라고 부릅니다.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
(PlaceViewController.m). 구현은 아래와 같습니다.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Place *placeAtIndex = (Place *)[appDelegate.PlacesArray objectAtIndex:indexPath.row];
NSLog(@"required lat long is %f, %f ", placeAtIndex.PlaceLatitude, placeAtIndex.PlaceLongitude);
CortesViewController *returnToMap = [[CortesViewController alloc] init];
float tableLatitude = placeAtIndex.PlaceLatitude ;
float tableLongitude = placeAtIndex.PlaceLongitude;
[returnToMap showAddress :tableLatitude :tableLongitude : 0];
[self.navigationController dismissModalViewControllerAnimated:YES];
}
코드는 서로 다른 위도와 경도가있는 곳을 클릭에도 불구하고 변하지 않는 내지도에서 오류 또는 경고 만보기없이 실행됩니다. showAddress는 PlaceViewController.m의 UITableView에 저장된 입력 값 lat, lon을 올바르게 사용합니다. 그러나
[mymap setCenterCoordinate:centerCoordinate animated:TRUE] ;
해달라고 라인은
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
에서 호출 할 때 작동하는 것.
도와주세요. 사전에 도움을 주셔서 감사합니다.
나는 ViewWillAppear 방법을 변경 않았고 완벽하게 일했다. 귀하의 답변에 감사드립니다. – alekhine