我有一个带有图钉的地图视图,当用户选择一个图钉时,它会转到该图钉的详细信息屏幕。我还有一个表格视图,当用户选择一个项目时,它会转到相同类型的详细视图。
我正在通过数组在 mapview 中添加多个引脚。我在附件视图中添加了按钮,
这就是问题所在...
当我点击按钮时,引脚选择会将他带到不同引脚的详细视图。但是在表格视图中它仍然可以正常工作..任何人请帮助我...?
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
MKPinAnnotationView *newAnnotation = nil;
if([annotation.title isEqualToString:@"You are here."])
{
newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"greenpin"];
newAnnotation.pinColor = MKPinAnnotationColorGreen;
}
else
{
newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"redpin"];
newAnnotation.pinColor = MKPinAnnotationColorRed;
UIButton *pinButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinButton.tag = indexvar;
[newAnnotation addSubview:pinButton];
newAnnotation.canShowCallout = YES;
newAnnotation.rightCalloutAccessoryView = pinButton;
newAnnotation.calloutOffset = CGPointMake(-5, 5);
indexvar++;
return newAnnotation;
[pinButton release];
}
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
return newAnnotation;
}
- (void)mapView:(MKMapView *)wikiMapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSInteger selectedIndex = ((UIButton *)control).tag;
NSLog(@"Property Index : %d ",selectedIndex);
DetailView = [[PropertyDetails alloc] initWithNibName:@"PropertyDetails" bundle:nil];
DetailView.propertyReference = [PropertyReferenceArr objectAtIndex:selectedIndex];
DetailView.propertyTitle = [propertyTitlesArr objectAtIndex:selectedIndex];
DetailView.propertyPrice = [propertyPriceArr objectAtIndex:selectedIndex];
DetailView.propertyBedrooms = [propertyBedroomsArr objectAtIndex:selectedIndex];
DetailView.propertyLatitude = [propertyLatitudesArr objectAtIndex:selectedIndex];
DetailView.propertyLongitude = [propertyLongitudesArr objectAtIndex:selectedIndex];
DetailView.propertyDefaultImage = [PropertyImageArr objectAtIndex:selectedIndex];
DetailView.propertyStatusId = [PropertyStatusArr objectAtIndex:selectedIndex];
[self.navigationController pushViewController:DetailView animated:YES];
[DetailView release];
}