---
title: "IPhone  之 UINavigationController"
author: "fireflylover"
date: "2011-12-26T23:14:49Z"
tags: []
categories: ["移动开发"]
slug: "iphone-uinavigationcontroller"
draft: false
lastmod: "2011-12-26T23:14:49Z"
id: 1326958
url: "https://fireflylover.iteye.com/blog/1326958"
---

1\. 创建Navigation-based application 工程

2. RootViewController.h

    #import &lt;UIKit/UIKit.h&gt;

```
@interface RootViewController : UIViewController {
	
}

-(IBAction)englishClick:(id)sender;
@end
```

 

3. RootViewController.m

 

   #import "RootViewController.h"

```
#import "English.h"

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	self.title = @"足球资料";
}

-(IBAction)englishClick:(id)sender{
	English *e=[[English alloc]initWithNibName:@"English" bundle:nil];
	e.title = @"英超";
	[self.navigationController pushViewController:e animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
}

- (void)dealloc {
    [super dealloc];
}

@end
```

 

4\. 在RootViewController.xib中加入一个按钮，绑定englishClick事件。

 

![](http://dl.iteye.com/upload/attachment/612066/a22e026f-3aaf-3658-8939-06c9f734aa49.png)

 

 

5.创建新文件选 UIViewController subclass, 在English.xib中添加label控件

 

6.运行程序

 

![](http://dl.iteye.com/upload/attachment/612077/19671989-542d-3f0d-974d-3fece698a1be.png)  ![](http://dl.iteye.com/upload/attachment/612079/108de04b-5790-38c3-b131-77c1286c9066.png)