標籤:des cWeb ar io os sp for java on
這一節主要介紹segues,static table view cells 和 Add Player screen 以及 a game picker screen。
Introducing Segues
開啟 Main.storyboard拖拉一個Bar Button Item到Players視窗導覽列的右側。在Attributes inspector中改變Identifier為Add,就會出現一個+號button。
當使用者點擊時會彈出一個模態視窗來輸入新的player的詳細資料。
拖拉一個新的navigation controller然後ctrl+drag來把之前的加號和這個view controller來串連。選擇modal。
這個串連就是所知的segue(seg-way)表示的是從一個螢幕到另一個螢幕的傳送。通過食用segue你不需要再為view間的顯示來寫代碼了。
運行代碼,點擊加號,一個新的頁面就出現了。
新建立一個PlayerDetailsViewController並且把之前modal中的table view controller的class設定為PlayerDetailsViewController。雙擊navigation bar把名稱修改為Add Player.添加cacel和done bar item。
PlayerDetailsViewController.h中進行下面的修改:
#import <UIKit/UIKit.h>
@class PlayerDetailsViewController;
@protocol PlayerDetailsViewControllerDelegater <NSObject>
- (void)playerDetailsViewControllerDidCancel:(PlayerDetailsViewController *)controller;
- (void)playerDetailsviewControllerDidSave:(PlayerDetailsViewController *)controller;
@end
@interface PlayerDetailsViewController : UITableViewController
@property (nonatomic, weak) id <PlayerDetailsViewControllerDelegater>delegate;
- (IBAction)cancel:(id)sender;
- (IBAction)done:(id)sender;
@end
Storyboards Tutorial (三)