使用Button删除注释

时间:2014-01-07 01:10:40

标签: ios annotations mapkit

我有一个按钮,当按下时淡出按钮并放入一组注释。有一个第二个按钮可以将按钮淡入,我需要它们也可以从地图中删除注释。我无法弄清楚如何将该功能联系起来并且可以使用一些帮助。这是我现在的代码。

    -(IBAction)fade:(id)sender{
    NSString *buttonText;
    if (sender == today2)
        buttonText = @"Today";
    else
        buttonText = @"Arcade";

    // Fade out autoview & scroller; fade in loadback
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelay:0.0];
    [UIView setAnimationDuration:1.0];
    [_autoview setAlpha:0];
    [UIView setAnimationDuration:1.0];
    [scroller setAlpha:0];
    [UIView setAnimationDelay:.5];
    [UIView setAnimationDuration:.2];
    [loadback setAlpha:1];
    [UIView commitAnimations];
    PFQuery *query = [PFQuery queryWithClassName:buttonText];
    CLLocation *currentLocation = locationManager.location;
    PFGeoPoint *point = [PFGeoPoint geoPointWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude];
    [query whereKey:@"location" nearGeoPoint:point withinMiles:50.0];
    [query includeKey:kPAWParseUserKey];


            // and add newPosts to allPosts.
            [mapView removeAnnotations:postsToRemove];
            [mapView addAnnotations:newPosts];
            [allPosts addObjectsFromArray:newPosts];
            [allPosts removeObjectsInArray:postsToRemove];

            self.mapPinsPlaced = YES;
        }
    }];


}



-(IBAction)fadein:(id)sender{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelay:0.0];
    [UIView setAnimationDuration:.5];
    [_autoview setAlpha:1];
    [UIView setAnimationDuration:.5];
    [scroller setAlpha:1];
    [UIView setAnimationDelay:.2];
    [UIView setAnimationDuration:.5];
    [loadback setAlpha:0];
    [UIView commitAnimations];

}

每当调用fadein动作但我不知道如何连接两者时,我需要删除注释。

0 个答案:

没有答案