2014-06-10 4 views
0
나 데이터를 검색하는 해석을 사용하고

저는 다른 뷰 컨트롤러에게 맵뷰를 갖는 viwecontroller에서 객체 ID,지도보기가있는보기 컨트롤러에서 다른보기 컨트롤러로 ID를 전달하는 방법은 무엇입니까?

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{ 

    [self performSegueWithIdentifier:@"MapToDeal" sender:view.annotation]; 
    NSLog(@"%@",view.annotation.title); 
} 
+0

위임자와 프로토콜을 사용할 수 있습니다. – lighter

+0

샘플 코드로 도울 수 있습니다 – mugunthan

+0

이 웹 사이트를 참조 할 수 있습니다 http://ios-blog.co.uk/tutorials/how-to-create-an-objective-c-delegate/ – lighter

답변

0

기록하는 .m 파일이 메소드를 전달 어떻게

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
if ([[segue identifier] isEqualToString: @"MapToDeal"]) 
    { 
    DetailViewController *detailViewController = [segue destinationViewController]; 

    detailViewController.annotview = sender; //here annoteview is object in DetailViewcontroller 
    } 
} 

또는 도 가능합니다.

In mapView Delegate method 

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control 
{ 
    [self performSegueWithIdentifier:@"MapToDeal" sender:view]; 
} 

In prepareForSegue: 

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if([[segue identifier] isEqualToString:@"MapToDeal"]) 
    { 
     MapPoint *annotation = (MapPoint *)view.annotation; 

     DetailViewController *dvc = segue.destinationViewController; 
     dvc.name = annotation.name; 
     dvc.anyproperty = annotation.anyproperty; 

    } 
} 
관련 문제