[iOS基础控件 - 3.1] QQ登陆界面

1 @interface ViewController ()
2 @property (weak, nonatomic) IBOutlet UITextField *qqField;
3 @property (weak, nonatomic) IBOutlet UITextField *pwdField;
4
5 - (IBAction)login;
6
7 @end
8
9 @implementation ViewController
10
11 - (void)viewDidLoad {
12 [super viewDidLoad];
13 // Do any additional setup after loading the view, typically from a nib.
14 }
15
16 - (void)didReceiveMemoryWarning {
17 [super didReceiveMemoryWarning];
18 // Dispose of any resources that can be recreated.
19 }
20
21 - (IBAction)login {
22 NSLog(@"%@ - %@", self.qqField.text, self.pwdField.text);
23 }
24 @end
1 @interface ViewController ()
2
3 - (void) addLabel;
4 - (void) addTextField;
5 - (void) addLoginButton;
6 - (void) login;
7
8 @end
9
10 @implementation ViewController
11
12 - (void)viewDidLoad {
13 [super viewDidLoad];
14 // Do any additional setup after loading the view, typically from a nib.
15
16 [self addLabel];
17 [self addTextField];
18 [self addLoginButton];
19 }
20
21 - (void)didReceiveMemoryWarning {
22 [super didReceiveMemoryWarning];
23 // Dispose of any resources that can be recreated.
24 }
25
26 - (void) addLabel {
27 UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 45, self.view.frame.size.width, 21)];
28 [titleLabel setTextAlignment:NSTextAlignmentCenter];
29 titleLabel.text = @"QQ登陆界面2";
30 [self.view addSubview:titleLabel];
31
32 UILabel *qqLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 91, 26, 21)];
33 qqLabel.text = @"QQ";
34 [self.view addSubview:qqLabel];
35
36 UILabel *pwdLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 131, 34, 21)];
37 pwdLabel.text = @"密码";
38 [self.view addSubview:pwdLabel];
39 }
40
41 - (void) addTextField {
42 UITextField *qqField = [[UITextField alloc] initWithFrame:CGRectMake(109, 87, 151, 30)];
43 qqField.placeholder = @"请输入QQ账号";
44 [qqField setClearButtonMode:UITextFieldViewModeWhileEditing];
45 [qqField setKeyboardType:UIKeyboardTypeNumberPad];
46 [qqField setBorderStyle:UITextBorderStyleRoundedRect];
47 [qqField setTag:1];
48 [self.view addSubview:qqField];
49
50 UITextField *pwdField = [[UITextField alloc] initWithFrame:CGRectMake(109, 127, 151, 30)];
51 pwdField.placeholder = @"请输入QQ密码";
52 [pwdField setSecureTextEntry:YES];
53 [pwdField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
54 [pwdField setClearButtonMode:UITextFieldViewModeWhileEditing];
55 [pwdField setBorderStyle:UITextBorderStyleRoundedRect];
56 [pwdField setTag:2];
57 [self.view addSubview:pwdField];
58 }
59
60 - (void) addLoginButton {
61 // 注意如果使用UIButtonTypeCustom,默认背景色和titleColor都是是白色,显示不出来
62 UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
63
64 CGRect loginRect = CGRectMake(145, 177, 30, 30);
65 loginButton.frame = loginRect;
66 [loginButton setTitle:@"登陆" forState:UIControlStateNormal];
67 [loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
68
69 [self.view addSubview:loginButton];
70 }
71
72 #pragma mark - action
73 - (void) login {
74 UITextField *qqField = [self.view viewWithTag:1];
75 UITextField *pwdField = [self.view viewWithTag:2];
76
77 NSLog(@"登陆---->%@ - %@", qqField.text, pwdField.text);
78 }
79 @end
[iOS基础控件 - 3.1] QQ登陆界面的更多相关文章
- [iOS基础控件 - 6.9.1] 聊天界面Demo 代码
框架: 所有代码文件: Model: // // Message.h // QQChatDemo // // Created by hellovoidworld on 14/12/8. // ...
- [iOS基础控件 - 5.5] 代理设计模式 (基于”APP列表"练习)
A.概述 在"[iOS基础控件 - 4.4] APP列表 进一步封装,初见MVC模式”上进一步改进,给“下载”按钮加上效果.功能 1.按钮点击后,显示为“已下载”,并且不 ...
- [iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理
A.需求 1.类似QQ.微信顶部或者底部的窗口转换导航条 2.给每个页面添加相应内容 B.UITabBarController 1.基本概念: (1)内容高度 iOS7之前内容高度为:屏幕高度 - ...
- [iOS基础控件 - 6.9.3] QQ好友列表Demo TableView
A.需求 1.使用plist数据,展示类似QQ好友列表的分组.组内成员显示缩进功能 2.组名使用Header,展示箭头图标.组名.组内人数和上线人数 3.点击组名,伸展.缩回好友组 code so ...
- iOS 基础控件(下)
上篇介绍了UIButton.UILabel.UIImageView和UITextField,这篇就简短一点介绍UIScrollView和UIAlertView. UIScrollView 顾名思义也知 ...
- [iOS基础控件 - 6.11.3] 私人通讯录Demo 控制器的数据传递、存储
A.需求 1.搭建一个"私人通讯录"Demo 2.模拟登陆界面 账号 密码 记住密码开关 自动登陆开关 登陆按钮 3.退出注销 4.增删改查 5.恢复数据(取消修改) 这个代码 ...
- [iOS基础控件 - 6.9] 聊天界面Demo
A.需求 做出一个类似于QQ.微信的聊天界面 1.每个cell包含发送时间.发送人(头像).发送信息 2.使用对方头像放在左边,我方头像在右边 3.对方信息使用白色背景对话框,我方信息使用蓝色背景对话 ...
- [iOS基础控件 - 7.0] UIWebView
A.基本使用 1.概念 iOS内置的浏览器控件 Safari浏览器就是通过UIWebView实现的 2.用途:制作简易浏览器 (1)基本请求 创建请求 加载请求 (2)代理监听webView加载, ...
- [iOS基础控件 - 6.10.2] PickerView 自定义row内容 国家选择Demo
A.需求 1.自定义一个UIView和xib,包含国家名和国旗显示 2.学习row的重用 B.实现步骤 1.准备plist文件和国旗图片 2.创建模型 // // Flag.h // Co ...
随机推荐
- mybatis知识点
1.Mybatis比IBatis比较大的几个改进是什么 a.有接口绑定,包括注解绑定sql和xml绑定Sql , b.动态sql由原来的节点配置变成OGNL表达式, c. 在一对一,一对多的时候引进了 ...
- Linux下Nginx+Tomcat整合的安装与配置
因为nginx处理静态页面的速度很快,并且是免费的,它还可以配置负载均衡的服务器集群来搭建多个tomcat,所以nginx+tomcat是企业搭 建javaee项目很好的选择.nginx主要是通过反向 ...
- VS2012 Build相关
最近写了一个小程序,用到了一些关于build方面的内容,google后,记录一下 1. VS工程下的bin和obj文件夹,bin文件夹下的debug和release文件夹,以及其中的文件 大家可以参考 ...
- eclipse不自动弹出提示(Alt+/ 快捷键失效)
转自:http://www.cnblogs.com/shaweng/archive/2013/09/26/3340016.html 主要有一下几种方法: 1.次方法用于没有一点提示的情况:依次打 ...
- 网站开发中的相对URL问题--JSP
问题描述: 入门网站开发时,我们会在相对URL问题上有疑惑.例如,在一个jsp页面中引入css外部文件, <link rel="stylesheet" hr ...
- 不能设置sublime text 2 为默认编辑器
今天遇到一个有趣的事情,当我设置 css 样式表的默认打开方式的时候,却始终无法设置成功,系统总是随机选取一种打开方式来打开文件.比如:pdf.DW.txt等方式. 我设置默认打开方式的步骤如下: 1 ...
- 三个入侵的必备小工具-lcx.exe、nc.exe、sc.exe
lcx.exe的使用方法 以前抓肉鸡都是通过1433弱口令,然后.. 但是发现很多服务器开了1433,3389,但是终端是连不上的,因为服务器本身是在内网,只对外开放了1433端口,幸好有lcx. ...
- poj3034Whac-a-Mole(dp)
链接 状态转移好想 不过有坑 大家都犯的错误 我也会犯 很正常 就是锤子可以移到n*n以外 要命的是我只加了5 以为最多不会超过5 WA了N久 才想到 上下两方向都可以到5 所以最多加10 以时 ...
- 如何在一个frame中调用另一个frame中的javascript函数
1.htm <script language="javascript">function test(){alert("测试")}</scrip ...
- MVC 5 的 EF6 Code First 入门
英文渣水平,大伙凑合着看吧…… 这是微软官方SignalR 2.0教程Getting Started with Entity Framework 6 Code First using MVC 5 系列 ...