私はTabBarアプリケーションと2つのビューを持っています。 1つのビューは、アノテーションとコールアウトなどを含むMKMapViewです。すべて正常に動作します。コールアウトの 'UIButtonTypeDetailDisclosure'ボタンをクリックすると、私の 'showDetails'関数が起動します(NSLOG ..)。 今、 'showDetails'でDetailViewをプッシュしたいと思います。私は残念ながら、これは何も(エラーなし/なしアクション)を行いませんpushViewController
またはpresentModalViewController
pushViewController issue
#pragma mark - MKMap methods
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if([annotation isKindOfClass:[CustomPlacemark class]])
{
MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[annotation title]];
newAnnotation.pinColor = MKPinAnnotationColorGreen;
newAnnotation.animatesDrop = YES;
newAnnotation.canShowCallout = YES;
newAnnotation.enabled = YES;
//newAnnotation.pinColor=MKPinAnnotationColorPurple;
NSLog(@"Created annotation at: %f %f", ((CustomPlacemark*)annotation).coordinate.latitude, ((CustomPlacemark*)annotation).coordinate.longitude);
[newAnnotation addObserver:self
forKeyPath:@"selected"
options:NSKeyValueObservingOptionNew
context:@"GMAP_ANNOTATION_SELECTED"];
UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"leftIconView.png"]];
newAnnotation.leftCalloutAccessoryView = leftIconView;
[leftIconView release];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
newAnnotation.rightCalloutAccessoryView = rightButton;
[newAnnotation autorelease];
return newAnnotation;
}
return nil;
}
- (void) showDetails:(id)sender {
NSLog(@"Annotation Click");
[self.navigationController pushViewController:self.detailViewController animated:YES];
// I want to push a new View here...
}
を使用するか必要があるだろう。私はpushViewController
を使用するためにnavigationController
を持っていないためだと思う。私が作成し、通知の中の私の「UIButtonTypeDetailDisclosure」ボタンをクリックしたときにnavigationControllerにDetailViewControllerをプッシュしようとしています
- (void) showDetails:(id)sender {
NSLog(@"Annotation Click");
[self.navigationController pushViewController:self.detailViewController animated:YES];
// I want to push a new View here...
}
。しかし、navigationControllerは無しです。 私の 'showDetails'関数に何を追加すればいいですか?
感謝
ありがとう、私はこれを試みたが、それは私のために働かない。警告:「no -detailController」メソッドが見つかりました と警告: 'UINavigationController'が '-detailController'に応答しない可能性があります... – Jan
なぜこの: 'UINavigationController * navigationController = [[UINavigationController alloc] detailController] ; '? ** 'initWithRootViewController' **または何かが必要です。 – WrightsCS
私はコードを編集しました。それは '[navigationController setView:detailController.view];'であるはずです。すみません、私の間違いです –