Note that there are some explanatory texts on larger screens.

plurals
  1. POusing mapView annotation in a tableView
    primarykey
    data
    text
    <p>I'm a beginner but have been working really hard to build this application. Working from another question I asked: <a href="https://stackoverflow.com/questions/5319669/mapkit-and-table-view-sample-code-iphone-sdk">mapkit and table view sample code - iPhone SDK</a></p> <p>I was able to put together a (semi-)functioning tableview and mapview. However, I'm not really sure how to call the mapview annotations to do numberOfRowsInSection or cellForRowAtIndexPath.</p> <p>the cellForRowAtIndexPath I'm sure isn't called properly but I'm thinking its a combo of both numberOfRowsInSection and cellForRowAtIndexPath.. But honestly I've been trying (and failing) for 3 weeks and reading all I can before I asked the question.</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { //return [[mapView annotations] count]; return 1; } </code></pre> <p>So I was trying to use the count of the mapview annotations but I'm not even sure if this is working. </p> <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]autorelease]; } NSMutableArray *annotations = [[NSMutableArray alloc] init]; //i'm sure the entire block below is pretty awful but i'm at a standstill for (MapLocation *annotation in [mapView annotations]) { [annotations addObject:annotation]; cell.textLabel.text = [[annotations objectAtIndex:indexPath.row]title]; } return cell; //i'm pretty sure this shouldn't be here </code></pre> <p>}</p> <p>If any other code is needed to help explain my situation just let me know.</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.
 

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