AppDelegateでナビゲーションコントローラーを宣言し、ナビゲーションコントローラーをルートビューコントローラーとして設定したと思います。シングルビューアプリケーションから始めたと仮定していない場合に備えて。
appdelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
ViewController *objViewController;
UINavigationController *objectNavigationController;
}
n.mファイル
objViewController =[[HomeViewController alloc]initWithNibName:@"ViewController" bundle:nil];
objectNavigationController = [[UINavigationController alloc]initWithRootViewController:objViewController];
self.window.rootViewController=objectNavigationController;
ボタンアクションにこれに似たコードを与えるだけで、次のViewControllerに移動します
-(IBAction)buttonClick:(id)sender
{
secondViewController *newObj = [[secondViewController alloc]initWithNibName:@"secondViewController" bundle:nil];
[self.navigationController pushViewController:newObj animated:YES];
}
n前のページに移動するためのボタンに関しては、ナビゲーションコントローラーは戻るボタンのように機能するボタンを提供します。
本当にボタンでポップしたい場合
-(IBAction)popBack:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
これでうまくいきます:)
お役に立てれば。