Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The type of data that you are passing should have code for them, adhering to the MKAnnotation protocol (namely, title, subtitle and coordinate). Then you pass on that annotation from view to view.</p> <p>For example (your code would be better), imagine a Hotspot class </p> <pre><code>@interface Hotspot : NSObject &lt;MKAnnotation&gt; @property (copy, nonatomic) NSString *title; @property (copy, nonatomic) NSString *subTitle; @property (copy, nonatomic) NSString *moreInfo; @property (copy, nonatomic) NSString *time; @property (copy, nonatomic) NSNumber *altitude, *accuracy; - (CLLocationCoordinate2D) coordinate; </code></pre> <p>In your mapView delegate class, you would do something like this:</p> <pre><code>- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{ DetailViewController *detailController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil]; detailController.hotspot = (Hotspot*)view.annotation; [self.navigationController pushViewController:detailController animated:YES]; [detailController release]; } </code></pre> <p>Then in your detailViewController, just display the info you want to display: description, title, images etc, as long as they are available in your Hotspot class.</p> <hr> <p>EDIT</p> <p>After reading your code, you have two choices: add a hotspot property in your PromoViewController or set the labels from the mapView:annotationView:calloutAccessoryControlTapped. </p> <p>I will go with the first one, which is much better from an encapsulation and design point of view.</p> <p>Change your PromoViewController header to </p> <pre><code>#import "Hotspot.h" @interface PromoViewController : UIViewController { IBOutlet UILabel *nameLabel; IBOutlet UILabel *detailLabel; IBOutlet UILabel *typeLabel; IBOutlet UILabel *contactLabel; IBOutlet UILabel *priceLabel; } @property (nonatomic, retain) Hotspot *hotspot; </code></pre> <p>And in your PromoViewController.m change the viewWillAppear: method to </p> <pre><code>- (void)viewWillAppear:(BOOL)animated{ nameLabel.text = hotspot.title; detailLabel.text = hotspot.detail; typeLabel.text = hotspot.subTitle; priceLabel.text = [NSString stringWithFormat:@"%0.2f", hotspot.price]; //And so on... } </code></pre> <p>You of course need to add @synthesize hotspot at the top of your PromoViewController.m </p>
 

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