ボタンがタップされたときに詳細ビューを追加しようとして、開示ボタン付きのピンがあります。
Apple の MapCallouts を参照として使用しています。エラーが発生します
アプリケーションが nil View Controller をターゲットにプッシュしようとした
彼らのコード例を使用して -
[self.navigationController pushViewController:self.detailViewController animated:YES];
間違った場所に実装していますか?エラーが発生する理由がわかりません。
#import、@class @interface @property @implementation @synthesize などのすべてをリンクするのに問題があります...何が何をするのかわかりません。
-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:
(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = nil;
if(annotation != mapView.userLocation)
{
static NSString *defaultPinID = @"com.invasivecode.pin";
pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
if ( pinView == nil ) pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
// add a detail disclosure button to the callout which will open a new view controller page
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
}
else {
[mapView.userLocation setTitle:@"Current Location"];
}
return pinView;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
id<MKAnnotation> myAnnotation = [self.mapView.annotations objectAtIndex:0];
[self.mapView selectAnnotation:myAnnotation animated:YES];
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
// code to show details view
MapDetailViewController *detailViewController = [[MapDetailViewController alloc] init];
// Adds the above view controller to the stack and pushes it into view
[self.navigationController pushViewController:detailViewController animated:YES];
// We can release it again, because it's retained (and autoreleases in the stack). You can also choose to autorelease it when you allocate it in the first line of code, but make sure you don't call release on it then!
[MapDetailViewController release];
}