越努力.越幸福.----willingseal.
UINavigationController的结构组成
--------
(1)新建一个工程,创建3个控制器类和3个视图,并关联视图和控制器,设置第一个view为蓝绿色,第二个view为黄色,第三个view为橘色。
(2)
在AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColorwhiteColor]; ListViewController * listVC= [[ListViewController alloc] initWithNibName:@"List_iphone"bundle:nil]; self.navController = [[UINavigationControlleralloc] initWithRootViewController:listVC]; [self.windowaddSubview:self.navController.view]; [self.windowmakeKeyAndVisible]; returnYES; }
(3)
点击第一个view中的button进入第二个页面
在ListViewController.m
- (void)viewDidLoad { [superviewDidLoad]; // Do any additional setup after loading the view. self.title = @"列表"; }
- (IBAction)push:(id)sender { TwoViewController *twoVC = [[TwoViewControlleralloc] initWithNibName:@"Two_iphone"bundle:nil]; [self.navigationControllerpushViewController:twoVCanimated:YES]; }
(4)
点击第二个view中的button进入第三个页面
在 TwoViewController.m
- (void)viewDidLoad { [superviewDidLoad]; // Do any additional setup after loading the view. self.title = @"Two"; } - (IBAction)toTwo:(id)sender { ThreeViewController *threeVC = [[ThreeViewControlleralloc] initWithNibName:@"Three_iphone"bundle:nil]; [self.navigationControllerpushViewController:threeVC animated:YES]; }
(5)
(6)源代码: