ボタンを使用してViewControllerを表示しているかどうかはわかりませんが、使用している場合は機能するはずです。以下のような新しい関数をViewControllerに作成します。これにより、ビューとビュー内のナビゲーションコントローラーがインスタンス化されるため、後で閉じることができます。
- (void)buttonPressed {
UIViewController *yourViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navigationController = [[UINavigationController] alloc] initWithRootViewController:yourViewController];
[self presentModalViewController:navigationController animated:YES];
}
そして、viewDidLoadには、次のようなものがあります(ボタンから表示する場合)。以下のコードはUIBarButtonItem用ですが、他のボタンも同様に機能するはずです。アクションパラメータを@selector(buttonPressed)、またはボタンが押されたときに呼び出す関数の名前に設定していることを確認してください。
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] init]
target:self
action:@selector(buttonPressed)];