2 lianlianbushell lianlianbushell 于 2013.08.09 11:15 提问

如何给detailVC发送数据

使用didSelectRowAtIndexPath:传递一些数据,从一个table视图控制器到一个detail视图控制器。

我现在要将数据从地图callOutAccessoryControlTapped:方法发送出去,但是不知道应该怎么实现。

应该怎么用callOutAccessoryControlTapped:发送detailViewController.descriptionTextViewString = [[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"short_description"];

其中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];
}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!