標籤:
之前一直在看OC基礎,這兩天才開始弄iOS開發的Demo,現在更多的學習資料都是xCode4.X的,發現xCode6.1還是改動了不少東西,很多功能需要瞭解一下,大概就是痛並快樂著,大神可以直接忽略我了,說來說去都是開發,具體看圖分析:
1.建立單視圖檔案:
2.建立項目名稱,語言選擇OC:
3.這個就是拖了兩個控制項放在View上面的,其中有一個比Android好的就是不需要自己建立模擬器,取消一下自動布局和auto size classes,不然頁面很大:
4.如果你只是簡單的寫個Hello World,那麼這個程式已經結束了,不過第一次還是做個事件:
5.新手錯誤之this class is not key value coding-compliant for the key result,這個就是連線連太多了,連錯了,結果串連那邊沒有刪除,具體修改如下:
6.運行效果如下:
7.代碼如下:
ViewController.h中代碼:
//// ViewController.h// Demo01//// Created by keso on 15/1/12.// Copyright (c) 2015年 keso. All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UIViewController@property (weak, nonatomic) IBOutlet UIView *name;@property (weak, nonatomic) IBOutlet UITextField *realName;@property (weak, nonatomic) IBOutlet UILabel *result;@end
ViewController.m中代碼:
//// ViewController.m// Demo01//// Created by keso on 15/1/12.// Copyright (c) 2015年 keso. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (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.}- (IBAction)showName:(id)sender { NSString *textName=[_realName text]; [_result setText:textName];}@end
iOS開發初體驗Demo