我几乎关注了这篇文章。视图控制器将通过情节提要推送。这里是相关代码:
ViewController.m:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"%@", view.annotation.title);
MapPoint *annView = view.annotation;
DetailViewController *dvc = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
dvc.title = @"my own Details";
dvc.titleTMP = annView.title;
dvc.subtitleTMP = annView.subtitle;
[self.navigationController pushViewController:dvc animated:YES];
}
地图点.h:
@interface MapPoint : NSObject <MKAnnotation>
{
NSString *_title;
NSString *_subtitle;
CLLocationCoordinate2D _coordinate;
UIImage *_storeImage;
}
@property (copy) NSString *title;
@property (copy) NSString *subtitle;
@property (nonatomic, readonly) UIImage *storeImage;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id)initWithTitle:(NSString*)title subtitle:(NSString*)subtitle coordinate:(CLLocationCoordinate2D)coordinate storeImage:(UIImage*)storeImage;
和 DetailViewController:
@interface DetailViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIImageView *branchImage;
@property (strong, nonatomic) IBOutlet UILabel *titleLabel;
@property (strong, nonatomic) IBOutlet UITextView *textView;
我认为我的错误在于calloutAccessoryControlTapped方法,但我不知道这个问题的真正原因是什么。