Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display a location from a table on a map on the next screen?
    primarykey
    data
    text
    <p>I am passing an NSArray that contains objects to a screen where the object properties are displayed in a table. Each of these objects contain a latitude property, and a longitude property. I would like to implement a functionality where the user selects a cell (where each cell represents an object from the NSArray), and the user is then taken to another screen where they can see an annotation representing the location of the object on a map, and an annotation representing the user. How do I do this? Here is my relevant code from my RootViewController.m class:</p> <pre><code>SecondViewController *controller = [[SecondViewController alloc] initWithNibName:@"SecondView" bundle:[NSBundle mainBundle]]; self.secondViewController = controller; [controller release]; self.secondViewController.locationList = sortedLocations; [[self navigationController] pushViewController:controller animated:YES]; </code></pre> <p>My relevant code in SecondViewController.m looks like this:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"locationcell"; LocationTableViewCell *cell = (LocationTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[LocationTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } Location *location = [locationList objectAtIndex:indexPath.row]; cell.locationName.text = location.name; cell.locationAddress.text = location.address; cell.locationDistance.text = location.distance; return cell; } </code></pre> <p>Please bear in mind that the visible properties are name, address, and distance, but the location object also contains latitude, and longitude properties. I know I have to create a new screen called MapViewController. But as I said, I really am not sure where to go from the table on the screen, to a map that shows the location object, and the user. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload