如何从callOutAccessoryControlTapped:方法向详细信息vc发送数据

时间:2013-08-08 12:09:18

标签: iphone ios objective-c didselectrowatindexpath

我正在使用didSelectRowAtIndexPath:使用下面的代码将表vc中的一些数据传递给详细信息vc。

我要做的是从地图callOutAccessoryControlTapped:方法发送此数据,但我不确定如何以这种方式发送数据。

我将如何发送   detailViewController.descriptionTextViewString = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"short_description"];
使用
     callOutAccessoryControlTapped:方法?

objectAtIndex:indexPath.row无法从地图callOutAccessoryControlTapped:方法中识别出来。

这是我的didSelectRowAtIndexPath:代码:

- (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];

}

这是我的地图注释calloutAccessoryControlTapped:方法

- (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 个答案:

答案 0 :(得分:1)

您可以使用以下方法获取tableView的选定索引:

NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];