_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
基本
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/*
* UIWindow に設定する
*/
CustomViewController *CustomViewController = [[CustomViewController alloc] init];
UINavigationController *CustomNavigationController = [[UINavigationController alloc] initWithRootViewController:CustomViewController];
CustomNavigationController.navigationBarHidden = YES;
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) {
// warning: addSubView doesn't work on iOS6
[self.window addSubview:CustomNavigationController.view];
} else {
// use this method on ios6
self.window.rootViewController = CustomNavigationController;
}
/*
* 画面遷移
*/
CustomViewController *viewController = [[CustomViewController alloc] init];
// 通常
[self.navigationController pushViewController:viewController animated:YES];
// モーダル
[self.navigationController presentModalViewController:tutorialViewController animated:YES];
// 一つ前に戻る
[self.navigationController popViewControllerAnimated:YES];
// 一番先頭へ戻る
[self.navigationController popToRootViewControllerAnimated:YES];
// 位置を指定して戻る
NSInteger viewCount = self.navigationController.viewControllers.count - 4;
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:viewCount] animated:YES];
/*
* タイトルのカスタマイズ
*/
UILabel *naviTitlelabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
naviTitlelabel.text = @"Title\nTitle";
self.navigationItem.titleView = naviTitlelabel;
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
画面遷移
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
UIViewController *vc = [[UIViewController alloc] init];
vc.view.backgroundColor = [UIColor redColor];
[self.navigationController pushViewController:vc animated:YES];
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
戻るボタン非表示
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
UINavigationControllerの戻るボタンで、何も設定しないと前画面のタイトルが設定される。
この戻るボタンを表示しないようにするには以下のように設定する。
[self.navigationItem setHidesBackButton:YES];
最終更新:2016年03月28日 10:11