目標:
1.storyBoard的介紹與使用
2.在不同viewController間傳送資料 使用storyBoard,
首先要確定是否有存在多個,如果有多個storyBoard,則可以在plist 檔案中的[Main storyboard file base name];則是指出哪一個storyBoard才是我們所使用的,在點選storyBoard,畫面會出現step 1 的按鈕,此按鈕可以用來開關 storyBoard下所有viewController的清單.在清單中可以拖曳來決定ViewController的開啓流程.感覺確實比用nib 的方式要直覺得
許多.
[img]http://dl.iteye.com/upload/attachment/0081/3240/86f54d4b-a79a-3d34-b553-47295e089b05.gif[/img]
此storyBoard共包含了三個viewController,本範例中共會使用到兩個,分別是root的UIStoryboardDemoViewController,以及按下go Value0的所出現的UIStoryboardSubViewController
[code]
#import "UIStoryboardDemoViewController.h"
@interface UIStoryboardDemoViewController ()
@end
@implementation UIStoryboardDemoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//過場傳送端
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//將資料送到destinationViewController
id secondCon =segue.destinationViewController;
[secondCon setValue:@"From Hello" forKey:@"dataString"];
}
[/code]
[code]
//
// UIStoryboardSubViewController.h
// StoryboardDemo0
//
// Created by Administrator on 13/3/7.
// Copyright (c) 2013年 Administrator. All rights reserved.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface UIStoryboardSubViewController : UIViewController
@property (strong) NSString *dataString;
@property (weak, nonatomic) IBOutlet UITextField *inputField;
- (IBAction)DoDone:(id)sender;
@end
[/code]
1.storyBoard的介紹與使用
2.在不同viewController間傳送資料 使用storyBoard,
首先要確定是否有存在多個,如果有多個storyBoard,則可以在plist 檔案中的[Main storyboard file base name];則是指出哪一個storyBoard才是我們所使用的,在點選storyBoard,畫面會出現step 1 的按鈕,此按鈕可以用來開關 storyBoard下所有viewController的清單.在清單中可以拖曳來決定ViewController的開啓流程.感覺確實比用nib 的方式要直覺得
許多.
[img]http://dl.iteye.com/upload/attachment/0081/3240/86f54d4b-a79a-3d34-b553-47295e089b05.gif[/img]
此storyBoard共包含了三個viewController,本範例中共會使用到兩個,分別是root的UIStoryboardDemoViewController,以及按下go Value0的所出現的UIStoryboardSubViewController
[code]
#import "UIStoryboardDemoViewController.h"
@interface UIStoryboardDemoViewController ()
@end
@implementation UIStoryboardDemoViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//過場傳送端
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//將資料送到destinationViewController
id secondCon =segue.destinationViewController;
[secondCon setValue:@"From Hello" forKey:@"dataString"];
}
[/code]
[code]
//
// UIStoryboardSubViewController.h
// StoryboardDemo0
//
// Created by Administrator on 13/3/7.
// Copyright (c) 2013年 Administrator. All rights reserved.
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface UIStoryboardSubViewController : UIViewController
@property (strong) NSString *dataString;
@property (weak, nonatomic) IBOutlet UITextField *inputField;
- (IBAction)DoDone:(id)sender;
@end
[/code]