English 中文(简体)
通过表格“观点和地图观点”通过数据?
原标题:Passing data through Table View and Map View... how does it work?

我有两点看法的塔巴。 一个是地图,另一个是搜索场的表。 在表格中,我通过JSON获得一些地方(坐标)。 我需要知道如何检索这些信息,以便将说明列入地图。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MapViewController *mvc = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil];

CLLocationCoordinate2D location;
titleLocation       = [ streets objectAtIndex:indexPath.row ];
location.latitude   = [ [ latitude objectAtIndex:indexPath.row ] doubleValue];
location.longitude  = [ [ longitude objectAtIndex:indexPath.row ] doubleValue];

[self.tabBarController setSelectedIndex:0];
[mvc release];

我知道,这不会奏效,但我不知道如何把这价值观通过给马普洛默勒或我的地图文典,然后把这些价值观带入地图集。 我认为,最后一点更好了。

Could you help me? Thanks a lot


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MapViewController *mvc = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil];

    CLLocationCoordinate2D location;
    titleLocation       = [ streets objectAtIndex:indexPath.row ];
    location.latitude   = [ [ latitude objectAtIndex:indexPath.row ] doubleValue];
    location.longitude  = [ [ longitude objectAtIndex:indexPath.row ] doubleValue];

    MapViewAnnotation *mva = [[MapViewAnnotation alloc] initWithTitle:titleLocation andSubtitle:@"Clique para fazer sua contribuição" andCoordinate:location];

    NSLog(@"Lat/Log: %f/%f", location.latitude, location.longitude);

    [mvc setAnnotation:mva];
    [mvc.mapView addAnnotation:mva]; 

    [self.tabBarController setSelectedIndex:0];
    [mvc release];  
}

我也这样说,但它依然没有工作。 说明没有出现。

问题回答

假设地图总是以表格索引0显示,你可以查阅<代码>。 页: 1 阵容:

MapViewController *mvc = (MapViewController *)
                     [self.tabBarController.viewControllers objectAtIndex:0];

CLLocationCoordinate2D location;
titleLocation       = [ streets objectAtIndex:indexPath.row ];
location.latitude   = [ [ latitude objectAtIndex:indexPath.row ] doubleValue];
location.longitude  = [ [ longitude objectAtIndex:indexPath.row ] doubleValue];

//Here, call some method in MapViewController that takes a location and title
//and creates an annotation from it and adds it to the map view...
[mvc makeAnnotationAtLocation:location title:titleLocation];

[self.tabBarController setSelectedIndex:0];

//(do not release mvc)

www.un.org/Depts/DGACM/index_french.htm 这种方法可以认为:

- (void)makeAnnotationAtLocation:(CLLocationCoordinate2D)coord title:(NSString *)locTitle
{
    YourAnnotationClass *yac = [[YourAnnotationClass alloc] init];
    yac.coordinate = coord;
    yac.title = locTitle;
    [mapView addAnnotation:yac];
    [yac release];

    //center map on coord if you want to...
}




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签