假設
界面1為 ViewController01 : UIViewController 界面2為 ViewController02 : UIViewController
其中界面1為項目的rootViewController.
AppDelegate.h代碼
C代碼

- #import <UIKit/UIKit.h>
- @interface AppDelegate : UIResponder <UIApplicationDelegate>
- @property (strong, nonatomic) UIWindow *window;
- @property (strong, nonatomic) NSString* localImagePath;
- @end
AppDelegate.m的部分代碼

- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- // Override point for customization after application launch.
- ViewController01* mViewController01 = [[ViewController01 alloc]init];
- self.window.rootViewController = mViewController01;
- self.window.backgroundColor = [UIColor whiteColor];
- [self.window makeKeyAndVisible];
- return YES;
- }
ViewController01.h代碼

- @interface ViewController01 : UIViewController
- @property (strong,nonatomic) NSMutableDictionary* parameter;
ViewController01.m代碼

- #import "ViewController01.h"
- #import "MyViewTool.h"
- #import "ViewController02.h"
- @interface ViewController01 ()
- @implementation ViewController01
- - (void)viewDidLoad {
- NSLog(@"viewDidLoad():視圖1");
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self initViews];
- [self initParameter];
- -(void)viewDidAppear:(BOOL)animated{
- NSLog(@"viewDidAppear():視圖1");
- [super viewDidAppear:animated];
- //接收到的參數
- NSLog(@"viewDidAppear():視圖1,收到的參數:from=%@",[self.parameter objectForKey:@"from"]);
- - (void)initViews{
- CGSize size = [MyViewTool loadScreenSize];
- CGFloat width = size.width;
- UILabel* label = [MyViewTool createLabel:CGRectMake(10, 40, width-20, 100) withText:@"視圖1" withBgcolor:[UIColor yellowColor]];
- UIButton* btn = [MyViewTool createButton:CGRectMake(label.frame.origin.x, label.frame.origin.y+label.frame.size.height+20, 200, 50) withDelegate:self withAction:@selector(buttonClick:) withTitle:@"按鈕1:點選打開視圖2"
- withBgColor:[UIColor lightGrayColor]];
- btn.center = CGPointMake(width/2, btn.center.y);
- [self.view addSubview:label];
- [self.view addSubview:btn];
- #pragma mark 初始化要傳遞的參數
- - (void)initParameter{
- self.parameter = [[NSMutableDictionary alloc]init];
- -(void)buttonClick : (UIButton*) sender {
- NSLog(@"buttonClick:%@",sender.titleLabel.text);
- //設定傳遞參數的資料
- [self.parameter setObject:@"我是視圖1設定的參數" forKey:@"from"];
- //打開 ViewController02
- ViewController02* mViewController02 = [[ViewController02 alloc]init];
- mViewController02.parameter=self.parameter;
- [self presentViewController:mViewController02 animated:YES completion:^{
- NSLog(@"presentViewController成功");
- }];
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
ViewController02.h代碼

- @interface ViewController02 : UIViewController
ViewController02.m代碼

- @interface ViewController02 ()
- @implementation ViewController02
- NSLog(@"viewDidLoad():視圖2");
- NSLog(@"viewDidAppear():視圖2");
- NSLog(@"viewDidAppear():視圖2,收到的參數:from=%@",[self.parameter objectForKey:@"from"]);
- UILabel* label = [MyViewTool createLabel:CGRectMake(10, 40, width-20, 100) withText:@"視圖2" withBgcolor:[UIColor yellowColor]];
- UIButton* btn = [MyViewTool createButton:CGRectMake(label.frame.origin.x, label.frame.origin.y+label.frame.size.height+20, 200, 50) withDelegate:self withAction:@selector(buttonClick:) withTitle:@"按鈕2:點選傳回視圖1" withBgColor:[UIColor lightGrayColor]];
- //設定傳回給視圖1的參數
- [self.parameter setObject:@"我是視圖2設定的參數" forKey:@"from"];
- [self dismissViewControllerAnimated:YES completion:^{
- NSLog(@"dismissViewControllerAnimated成功");
項目源代碼參見附近中的demo010.zip