我有一个地图视图,并且在用户选择一根插针时会进入该插针的详细信息页面。我还有一个表格视图,当用户选择项目时也会进入相同类型的详细信息视图。
问题是...
它似乎在从3.1.3到4.1的所有版本中都能正常工作。也就是说,详细视图与插针匹配。但是我有一个用户刚刚升级到iOS 4.2并表示,在4.1下它工作得很好,但在4.2中,插针选择会将其带到不同插针的详细信息页面。但在表格视图中,它仍然可以正常工作。
是否可能在iOS 4.2中更改了MKMapView,从而更改了如何选择pinID?
附加说明-我已添加了viewForAnnotation和checkButtonTapped的相关部分。
问题是...
它似乎在从3.1.3到4.1的所有版本中都能正常工作。也就是说,详细视图与插针匹配。但是我有一个用户刚刚升级到iOS 4.2并表示,在4.1下它工作得很好,但在4.2中,插针选择会将其带到不同插针的详细信息页面。但在表格视图中,它仍然可以正常工作。
是否可能在iOS 4.2中更改了MKMapView,从而更改了如何选择pinID?
附加说明-我已添加了viewForAnnotation和checkButtonTapped的相关部分。
- (MKPinAnnotationView *)mapView:(MKMapView *)eMapView viewForAnnotation:(id <MKAnnotation>)annotation {
int postTag = 0;
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[eMapView dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
if(pinView == nil) {
pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"];
pinView.frame = CGRectMake(0, 0, 25, 25);
} else {
pinView.annotation = annotation;
}
// Set up the Right callout
UIButton *myDetailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
myDetailButton.frame = CGRectMake(0, 0, 23, 23);
myDetailButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
myDetailButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[myDetailButton addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
// Identify which pin is being selected
if ([[annotation title] isEqualToString:@"Current Location"]) {
postTag = 99999;
} else {
postTag = [annotation getPinID];
}
myDetailButton.tag = postTag;
pinView.rightCalloutAccessoryView = myDetailButton;
pinView.animatesDrop = YES;
// Set to show a callout on the pin
pinView.canShowCallout = YES;
return pinView;
}
// Method to show detail view when the callOut button is selected
- (IBAction) checkButtonTapped: (id) sender {
int nrButtonPressed = ((UIButton *)sender).tag;
if (nrButtonPressed < 99999) {
if (self.showDetailView == nil) {
DetailData *tmpViewController = [[DetailData alloc] initWithNibName:@"Detail" bundle:nil];
self.showDetailView = tmpViewController;
[tmpViewController release];
}
buttonDetail = [[mapView annotations] objectAtIndex:(nrButtonPressed-1)];
NSMutableArray *tmpArray = [NSMutableArray arrayWithObjects: [buttonDetail getDataI], [buttonDetail getDataII], [buttonDetail getDataIII], [buttonDetail getDataIV], [buttonDetail getDataV], nil];
self.showDetailView.eventData = [[NSMutableArray alloc] initWithArray:tmpArray copyItems:YES];
[self.navigationController pushViewController:self.showDetailView animated:YES];
[self.showDetailView.eventData release];
}
正如您所看到的,在checkButtonTapped函数中,我记录了所选的pin,然后收集该pin的注释数据。问题似乎在于nrButtonPressed现在不正确了。但是在4.1版本中编译时没有问题。