calloutAccessoryControlTapped
に触れたときに詳細ビューコントローラーにプッシュしたい地図注釈があります。私が抱えている問題は、すべての注釈がすべて同じデータを詳細 VC に送信することです。indexPath が間違っているかどうかはわかりません。各地図の注釈は、吹き出しボックスに正しい情報を表示します。calloutAccessoryControlTapped
タップすると、配列の最初のリストに同じ情報がプッシュされるようです。
それは NSNumber *catListingMapId
; 私が本当にアクセスして詳細VCに渡す必要がある注釈で(そして、そのcatListingMapIdに基づいてデータをダウンロードします)。
- (void)mapView:(MKMapView *)mv annotationView:(MKAnnotationView *)pin calloutAccessoryControlTapped:(UIControl *)control {
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
MyAnnotation *theAnnotation = (MyAnnotation *) pin.annotation;
NSLog(@"the Annotation %@",theAnnotation.catListingMapId);
detailViewController.listingId = theAnnotation.catListingMapId;
// detailViewController.listingId = [[self.listingNodesArray objectAtIndex:selectedIndexPath] objectForKey:@"id"];
NSNumber *catNumber = [NSNumber numberWithInt:[catID intValue]];
detailViewController.catId = catNumber;
NSLog(@"detailViewController.listingId %@",detailViewController.listingId );
[self.navigationController pushViewController:detailViewController animated:YES];
}
ここに私の myAntoationMap ファイルがあります:
@interface MyAnnotation : NSObject<MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString* title;
NSString* subtitle;
NSNumber *latString;
NSNumber *lngString;
NSNumber *catMapId;
NSNumber *catListingMapId;
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* subtitle;
@property (nonatomic,copy) NSNumber *latString;
@property (nonatomic,copy) NSNumber *lngString;
@property (nonatomic,copy) NSNumber *catMapId;
@property (nonatomic,copy) NSNumber *catListingMapId;
@end
and the .m
#import "MyAnnotation.h"
@implementation MyAnnotation
@synthesize title;
@synthesize subtitle;
@synthesize coordinate;
@synthesize latString,lngString;
@synthesize catMapId;
@synthesize catListingMapId;
- (void)dealloc
{
[super dealloc];
self.title = nil;
self.subtitle = nil;
self.latString = nil;
self.lngString = nil;
self.catMapId = nil;
self.catListingMapId = nil;
}
@end