MapAnnotation iOS 7

时间:2014-02-14 19:55:13

标签: ios objective-c

我有一个MapAnnotation,我添加了自定义字段,所以当用户点击图钉时,我执行一个segue到另一个视图控制器,我尝试将标签设置为这些自定义字段。问题是我没有在veiwcontroller中获得值,因此它不会持久存在。我是iOS开发人员的新手,所以我可能错过了一些东西。

这是我设置MapAnnotation

的地方
 NSArray *json = [NSJSONSerialization JSONObjectWithData:data
                                                options:kNilOptions
                                                  error:&error];

for (MapAnnotation *record in json) {

  //  NSLog(@"%lu", (unsigned long)json.count);

    MapAnnotation *temp = [[MapAnnotation alloc]init];
    [temp setTitle:[record valueForKey:@"city"]];
    [temp setSubtitle:[record valueForKey:@"region"]];
    [temp setHeatmap:[record valueForKey:@"iframe_heatmap_url"]];
    [temp setPercentViewed:[record valueForKey:@"percent_viewed"]];
    [temp setOrg:[record valueForKey:@"org"]];
    [temp setEmbedURL:[record valueForKey:@"embed_url"]];
    [temp setCoordinate:CLLocationCoordinate2DMake([[record valueForKey:@"lat"]floatValue], [[record valueForKey:@"lon"]floatValue])];
    [retval addObject:temp];

我需要做些什么才能将其保存到其他视图控制器?我只是将MapAnnotation类导入到视图控制器中,并将标签文本设置为我的自定义类中的字段:

自定义注释类

@interface MapAnnotation : NSObject<MKAnnotation>

@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, copy) NSString *org;
@property (nonatomic, copy) NSString *percentViewed;
@property (nonatomic, copy) NSString *heatmap;
@property (nonatomic, copy) NSString *embedURL;

@end

0 个答案:

没有答案