HI我要求在MKMapAnnotationView中实现Next和Previous功能,如图所示。我已经从Here获得了用于进行自定义注释的引用但是如何通过单击Next和更改下一个或上一个注释上一个按钮。请提供一些关于此的提示或想法。我现在正在堆叠。
答案 0 :(得分:0)
为此,您可以使用rightCalloutAccessoryView
和leftCalloutAccessoryView
。
以下是如何使用rightCalloutAccessoryView
。
-(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation: (id<MKAnnotation>)annotation {
if ([annotation isKindOfClass: [MKUserLocation class]]) {
return nil;
}
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
[pinView setCanShowCallout:YES];
if([annotation isKindOfClass:[ASPinAnnotation class]])
{
[pinView setPinColor:MKPinAnnotationColorRed];
}
else if([annotation isKindOfClass:[ASAddAutomatPin class]])
{
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:[annotation title] forState:UIControlStateNormal];
[pinView setRightCalloutAccessoryView:rightButton];
[pinView setPinColor:MKPinAnnotationColorPurple];
}
要点击calloutAccessoryView时收到通知,您必须在委托中使用此功能:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
if([(UIButton*)control buttonType] == UIButtonTypeDetailDisclosure)
{
ASAddViewController *addController = [[ASAddViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addController];
[addController setDelegate:self];
[self.controller presentViewController:navController animated:YES completion:nil];
}
}