将objectId传递给新视图

时间:2013-11-24 00:12:44

标签: ios parsing view

我有一组注释,可以将您带到新视图并在其上显示解析信息。我不相信新视图会抓住每个地理点的objectId,因为标签不起作用。

这是我的代码:

- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id<MKAnnotation>)annotation {
// Let the system handle user location annotations.
if ([annotation isKindOfClass:[MKUserLocation class]]) {
    return nil;
}

static NSString *pinIdentifier = @"CustomPinAnnotation";

// Handle any custom annotations.
if ([annotation isKindOfClass:[PAWPost class]])
{

    // Try to dequeue an existing pin view first.
    MKPinAnnotationView *pinView = (MKPinAnnotationView*)[aMapView dequeueReusableAnnotationViewWithIdentifier:pinIdentifier];

    if (!pinView)
    {
        // If an existing pin view was not available, create one.
        pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
                                                  reuseIdentifier:pinIdentifier];
    }
    else {
        pinView.annotation = annotation;
    }
    static NSString* BridgeAnnotationIdentifier = @"bridgeAnnotationIdentifier";
    MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:BridgeAnnotationIdentifier];
    pinView.pinColor = MKPinAnnotationColorPurple;
    pinView.animatesDrop = YES;
    pinView.canShowCallout = YES;
    pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];


    return pinView;
}

return nil;
}

这是对新视图的推动。

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{

DetailViewController  *objDetail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];


objDetail.pawpost = (PAWPost *)view.annotation;
[self.navigationController pushViewController:objDetail animated:YES];
}

这是新视图页面上的代码。

    [super viewDidLoad];
PFObject *gameScore = [PFObject objectWithClassName:@"Arcade"];
self.title = @"Detail View";
PFQuery *query = [PFQuery queryWithClassName:@"Arcade"];
NSString *objectId = gameScore.objectId;
[query getObjectInBackgroundWithId:ObjectIdentifier block:^(PFObject *gameScore, NSError *error) {
    lblTitle.text = gameScore[@"name"];
    NSLog(@"%@", gameScore);
}];

0 个答案:

没有答案