2013-08-08 3 views
0

didSelectRowAtIndexPath:을 사용하면 아래의 코드를 사용하여 테이블 vc의 데이터를 세부적인 vc로 전달할 수 있습니다.callOutAccessoryControlTapped에서 데이터를 상세 vc로 보내는 방법 : 메서드

내가하려는 것은지도 callOutAccessoryControlTapped: 방법에서이 데이터를 보내는 것이지만 데이터를 보내는 방법은 확실하지 않습니다. 에있어서, 상기
callOutAccessoryControlTapped를 사용

내가 보내는 것 어떻게
detailViewController.descriptionTextViewString = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"short_description"];
?

objectAtIndex:indexPath.rowcallOutAccessoryControlTapped: 방법으로는 알 수 없습니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    ScrollView_ExampleViewController *detailViewController = [[ScrollView_ExampleViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 

    detailViewController.latStr = [[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"address"] objectForKey:@"lat"]; 
    detailViewController.lngStr = [[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"address"] objectForKey:@"lng"]; 

    detailViewController.addressStr = [[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"address"] objectForKey:@"address"]; 
    detailViewController.titleStr = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"title"]; 

    detailViewController.mainImageUrl = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"image"]; 

    detailViewController.listingId = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"id"]; 

    detailViewController.descriptionTextViewString = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"short_description"]; 

    [self.navigationController pushViewController:detailViewController animated:YES]; 

} 

가 여기 내지도 주석의

- (void)mapView:(MKMapView *)mv annotationView:(MKAnnotationView *)pin calloutAccessoryControlTapped:(UIControl *)control { 
    ScrollView_ExampleViewController *detailViewController = [[ScrollView_ExampleViewController alloc] initWithNibName:@"ScrollView_ExampleViewController" bundle:nil]; 

    MyAnnotation *theAnnotation = (MyAnnotation *) pin.annotation; 

    detailViewController.titleStr = theAnnotation.title; 
    detailViewController.addressStr = theAnnotation.subtitle; 
    // detailViewController.latStr = theAnnotation.latString; 
    // detailViewController.lngStr = theAnnotation.lngString; 

    // detailViewController.url = theAnnotation.theUrl; 

    [self.navigationController pushViewController:detailViewController animated:YES]; 
} 

답변

1

당신은있는 tableView의 선택된 인덱스 얻기 위해 다음과 같은 방법을 사용할 수 있습니다 calloutAccessoryControlTapped: 방법 :

NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];

+0

여기 내 didSelectRowAtIndexPath: 코드입니다 감사! calloutAccessoryControlTapped : 메소드에 추가했지만 indexPath.row가 인식되도록 변경하는 방법 : detailViewController.descriptionTextViewString = [[publicDataArray objectAtIndex : indexPath.row] objectForKey : @ "short_description"]; – user2588945

+0

indexPath.row를 selectedIndexPath로 변경해야합니까? – user2588945

+1

calloutAccessoryControlTapped에'detailViewController.descriptionTextViewString'을 설정하려면 다음과 같이 selectedIndexPath를 사용해야합니다. 'detailViewController.descriptionTextViewString = [[publicDataArray objectAtIndex : selectedIndexPath.row] objectForKey : @ "short_description"]] ; ' –