Передать значение аннотации вывода массива в JSON

Я новичок в xcode, и я надеюсь, что кто-то может помочь мне с моим кодом и указать мне, как решить мою проблему. Я искал в Интернете, но на самом деле я не мог понять это.

Как я могу перейти от вида карты к подробному виду, принеся с собой "ID" булавки и распечатав его на этикетке. когда я нажимаю на стрелку для аннотации, мой симулятор падает.

Пожалуйста, есть идеи, как подойти и решить это?

(в основном я хочу получить идентификатор булавки и отправить его на сервер через JSON, а затем перейти к подробному представлению, но следующий шаг)

Вот что я сделал до сих пор:

My Location.m (просмотр контроллера на карте)

#import "My_Location.h"
#import "DetailViewController.h"

// ------ FUNCTION TO GET COORDINATES IN JSON FORMAT -------

- (void)retrieveData_Location
{

    NSURL * url = [NSURL URLWithString:@"............./Pharmacies.php"];
    NSData * data = [NSData dataWithContentsOfURL:url];
    NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
    NSMutableArray *newAnnotations = [NSMutableArray array];

    CLLocationCoordinate2D location;

    for (NSDictionary *dictionary in array)
    {
    MKPointAnnotation *newAnnotation = [[MKPointAnnotation alloc] init];

    location.latitude = [dictionary[@"lat"] doubleValue];
    location.longitude = [dictionary[@"lon"] doubleValue];   
    newAnnotation.title = dictionary[@"name"];
    newAnnotation.coordinate = location;

    [newAnnotations addObject:newAnnotation];

    [newAnnotation release];      
}
    [self.MyLocation addAnnotations:newAnnotations];   
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation {

if([annotation isKindOfClass:[MKUserLocation class]])
    return nil; 
static NSString *identifier = @"myAnnotation";
MKPinAnnotationView * annotationView = (MKPinAnnotationView*)[self.MyLocation    dequeueReusableAnnotationViewWithIdentifier:identifier];
if (!annotationView)
{
    annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
    annotationView.pinColor = MKPinAnnotationColorPurple;
    annotationView.animatesDrop = YES;
    annotationView.canShowCallout = YES;
}else {
    annotationView.annotation = annotation;
}
    annotationView.rightCalloutAccessoryView = [UIButton   buttonWithType:UIButtonTypeDetailDisclosure];
    return annotationView;
}


- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view   calloutAccessoryControlTapped:(UIControl *)control
{
    [self performSegueWithIdentifier:@"Details" sender:view];

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"Details"])
    {
        MKAnnotationView *annotationView = sender;
        [segue.destinationViewController setAnnotation:annotationView.annotation];
    }
}

Take_Photo - мой детальный обзор контроллера.

И мой рассказ выглядит так:

Контроллер Mylocation View -> ( Segue: идентификатор ( Take_Photo)) -> Контроллер представления Take_Photo

0 ответов

Другие вопросы по тегам