http://www.cnblogs.com/heyonggang/p/3664565.html
来源:互联网 发布:社保网络认证软件下载 编辑:程序博客网 时间:2024/06/09 20:21
本地服务器实现登陆验证功能http://www.cnblogs.com/ios8/archive/2013/11/11/ios-login-json.html 原帖链接
1 #import "ViewController.h" 2 3 @interface ViewController () 4 5 @end 6 7 @implementation ViewController 8 9 - (void)viewDidLoad 10 { 11 [super viewDidLoad]; 12 // Do any additional setup after loading the view, typically from a nib. 13 14 //三个UILabel 15 UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 80, 37)]; 16 nameLabel.font = [UIFont systemFontOfSize:15]; 17 nameLabel.text = @"用 户 名:"; 18 nameLabel.backgroundColor = [UIColor clearColor]; 19 nameLabel.textAlignment = NSTextAlignmentLeft; 20 nameLabel.numberOfLines = 2; //用于设置UILabel中文本的行数 21 [self.view addSubview:nameLabel]; 22 [nameLabel release]; 23 24 UILabel *newPasswordLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60+40, 80, 37)]; 25 newPasswordLabel.font = [UIFont systemFontOfSize:15]; 26 newPasswordLabel.text = @"密 码:"; 27 newPasswordLabel.backgroundColor = [UIColor clearColor]; 28 newPasswordLabel.textAlignment = NSTextAlignmentLeft; 29 [self.view addSubview:newPasswordLabel]; 30 [newPasswordLabel release]; 31 32 UILabel *oncePasswordLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60+40*2, 80, 37)]; 33 oncePasswordLabel.font = [UIFont systemFontOfSize:15]; 34 oncePasswordLabel.text = @"确认密码:"; 35 oncePasswordLabel.backgroundColor = [UIColor clearColor]; 36 oncePasswordLabel.textAlignment = NSTextAlignmentLeft; 37 [self.view addSubview:oncePasswordLabel]; 38 [oncePasswordLabel release]; 39 40 41 //三个输入框 42 UITextField *nameTextField = [[UITextField alloc]initWithFrame:CGRectMake(90, 60, 210, 30)]; 43 nameTextField.placeholder = @"请输入用户名"; 44 nameTextField.tag = 1; 45 [nameTextField setSecureTextEntry:NO]; 46 nameTextField.font = [UIFont systemFontOfSize:14]; 47 nameTextField.delegate = self; 48 nameTextField.backgroundColor = [UIColor clearColor]; 49 nameTextField.borderStyle = UITextBorderStyleRoundedRect; 50 [self.view addSubview:nameTextField]; 51 [nameTextField release]; 52 53 UITextField *passwordTextField = [[UITextField alloc]initWithFrame:CGRectMake(90, 60+40, 210, 30)]; 54 passwordTextField.placeholder = @"至少6位数字"; 55 passwordTextField.tag = 2; 56 [passwordTextField setSecureTextEntry:YES]; 57 passwordTextField.font = [UIFont systemFontOfSize:14]; 58 passwordTextField.delegate = self; 59 passwordTextField.backgroundColor = [UIColor clearColor]; 60 passwordTextField.borderStyle = UITextBorderStyleRoundedRect; 61 passwordTextField.keyboardType = UIKeyboardTypeNumberPad; 62 [self.view addSubview:passwordTextField]; 63 [passwordTextField release]; 64 65 UITextField *onceNewPasswordTextField = [[UITextField alloc]initWithFrame:CGRectMake(90, 60+40*2, 210, 30)]; 66 onceNewPasswordTextField.placeholder = @"请再次输入密码"; 67 onceNewPasswordTextField.tag = 3; 68 onceNewPasswordTextField.font = [UIFont systemFontOfSize:14]; 69 [onceNewPasswordTextField setSecureTextEntry:YES]; 70 onceNewPasswordTextField.delegate = self; 71 onceNewPasswordTextField.backgroundColor = [UIColor clearColor]; 72 onceNewPasswordTextField.borderStyle = UITextBorderStyleRoundedRect; 73 onceNewPasswordTextField.keyboardType = UIKeyboardTypeNumberPad; 74 [self.view addSubview:onceNewPasswordTextField]; 75 [onceNewPasswordTextField release]; 76 77 78 UIButton *confirmButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 79 confirmButton.frame = CGRectMake(110, 60+40*3+20, 100, 37); 80 [confirmButton setTitle:@"确定" forState:UIControlStateNormal]; //正常状况下button显示的标题 81 [confirmButton setTitle:@"确定" forState:UIControlStateHighlighted]; //高亮显示时button的标题 82 confirmButton.backgroundColor = [UIColor redColor]; 83 [confirmButton addTarget:self action:@selector(confirm:) forControlEvents:UIControlEventTouchUpInside];//button被按下又抬起后发生的事件 84 //@selector可以理解为"选择子",selector是一个指针变量,类似于sender。 这里是将method的方法指定给新建的这个confirmButton 85 [self.view addSubview:confirmButton]; 86 } 87 88 //收回键盘 遵循代理实现键盘回收功能 89 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 90 { 91 for (int i = 0; i<4; i++) { 92 UITextField *textField = (UITextField*)[self.view viewWithTag:1+i]; 93 [textField resignFirstResponder]; 94 } 95 } 96 97 - (void)didReceiveMemoryWarning 98 { 99 [super didReceiveMemoryWarning];100 // Dispose of any resources that can be recreated.101 }102 103 @end
0 0
- http://www.cnblogs.com/heyonggang/p/3664565.html
- http://www.cnblogs.com/flylovesky/p/3274869.html
- http://www.cnblogs.com/ada-zheng/p/3284660.html
- http://www.cnblogs.com/zhanghaiba/p/3548602.html
- http://www.cnblogs.com/scy251147/p/3566638.html
- http://www.cnblogs.com/amosli/p/3577645.html
- http://www.cnblogs.com/VisualImage/p/3594973.html
- http://www.cnblogs.com/kuangbin/p/3164106.html
- http://www.cnblogs.com/wengzilin/p/3530712.html
- http://www.cnblogs.com/qingjoin/p/3549325.html
- http://www.cnblogs.com/interdrp/p/3785164.html
- http://www.cnblogs.com/ruiati/p/3930732.html
- http://www.cnblogs.com/knowledgesea/p/3491214.html
- http://www.cnblogs.com/ganganloveu/p/3755191.html
- http://www.cnblogs.com/kenshincui/p/3885689.html
- http://www.cnblogs.com/lanxuezaipiao/p/3440471.html
- http://www.cnblogs.com/wangfupeng1988/p/4001284.html
- http://www.cnblogs.com/kissazi2/p/4133927.html
- mysql交互式连接&非交互式连接
- C++项目中的extern "C" {}
- 设计模式个人理解总结
- interactive association rules exploration app
- shell脚本模拟多进程(讲的比较明白)
- http://www.cnblogs.com/heyonggang/p/3664565.html
- WindowManager.LayoutParams:(一:Flags)
- IO流--拷贝图片
- 网站开发进阶(二十三)Address already in use: JVM_Bind <null>:8088
- Android新建项目选择SDK的区别
- 如何跳到系统设置里的WiFi界面
- JavaScript图片加载和JQuery图片加载问题
- 黑马程序员-Java的面向对象(对象、类和封装)
- 南大软院大神养成计划——第十六天