现在更多的学习资料都是xCode4.X的,发现xCode6.1还是很多东西,如果有正在学习iOS开发的可以通过Demo简单了解下iOS的UI开发~
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