1. 需求描述html
2. 開發環境介紹ios
3. 建立一個工程app
4. 工程配置介紹iphone
5. 目錄結構介紹ui
6. 界面設置atom
7. 關聯輸入輸出spa
8. 關聯事件代碼設計
9. 運行結果3d
10. UITextField Class code
在遊戲開始以前,咱們都須要填寫咱們的角色名,來實現對話。要求用戶輸入角色名,點擊確認後,在下方展現「親愛的xx,咱們即將踏上一段神奇的探險之旅!」
OS X EI Captian:10.11.4
Xcode: 7.3
ios:9.3
機型:iphone 6s/iphone 6s plus
Xcode 英文版:
1.「Create a new Xcode project」(建立一個新的工程)
2.「Choose a template for your new project」(建立一個什麼樣的工程),咱們選擇 iOS > Application > Single View Application
3. 「Choose options for your new project」(配置你的工程選項),
Bundle Identifier(至關於包名的概念), Language : Objective-C , Devices: iPhone , Use Core Data: No, include Unit Tests: YES, include UI Tests: YES
4.保存工程目錄,工程建立完畢
File > Project Settings,配置iOS的版本爲:9.3
TARGETS配置
General :通用 Capabilities:系統功能受權配置 Resource Tags:資源標籤 Info:信息 Build Settings:編譯配置 Build Phases:編譯的依賴配置 Build Rules :編譯規則
本次應用使用默認配置
「Show the Project navigator 」(查看工程目錄)
AppDelegate : 應用事件委託AppDelegate.h(頭文件) AppDelegate.m ViewController: 控制器層,主要負責於視圖交互。 Main.storyboard: 主要的視圖文件,XML規範文件,在Xcode裏面能夠可視化操做。 Assets.xcassets: 資源文件的集合,好比圖片,圖標等 LaunchScreen.storyboard:Launch 時展現的視圖。 Info.plist:info數據的集合,類型有string、array等數據 Main.m :入口文件
「Main.storyboard」> "Show the Object Library" (界面組件)
Text Field :文本輸入框 Label : 文本 Button:按鈕
拖動完成以下的界面:
在ViewController.h中加入
@property (weak, nonatomic) IBOutlet UITextField *name;
@property (weak, nonatomic) IBOutlet UILabel *text;
以下視圖,選中控件,右鍵拖動到對應的代碼串進行關聯。
在ViewController.h中加入
- (IBAction)submit:(id)sender;
以下圖所示,操做方式同關聯輸入輸出口相似,主要是須要選擇Action和具體的事件。
Touch Down 觸摸按下
編寫事件代碼,ViewController.m:
- (IBAction)submit:(id)sender { NSString * str = [NSString stringWithFormat:@"親愛的%@,咱們即將踏上一段神奇的探險之旅!",self.name.text]; [self.text setText:str]; }
文章結束!
UITextField Class Reference
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/index.html