0

この投稿をほぼフォローしました。ビューコントローラーはストーリーボード経由でプッシュします。関連するコードは次のとおりです:
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];
}

MapPoint.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メソッドにあると思いますが、この問題の本当の理由はわかりません。

4

2 に答える 2

1

If you use a storyboard, can use prepareForSegue method and set within a class similarly as you have made.

I post a portion of code

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

if([segue.identifier isEqualToString:@"Brs"]){
    NSLog(@"segue %@ ",[segue identifier]);
    [segue.destinationViewController setPath:[ris_xml objectAtIndex:index_post-1] ];
    }
}

In this example I set attribute "Path" of next UIViewController only if his identifier is "Brs". For use this method is need set UIviewController identifier into storyboard right panel. Using this isn't need to instantiate new UIViewController if you have it in storyboard.

于 2013-04-22T21:16:30.630 に答える