UI4_注册登录界面
//
// ViewController.h
// UI4_注册登录界面
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h>
#import "RegisterViewController.h" @interface ViewController : UIViewController <UITextFieldDelegate,SendDelegateReport> @end //
// ViewController.m
// UI4_注册登录界面
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h"
#import "RegisterViewController.h"
#import "LoginViewController.h" @interface ViewController ()
{
RegisterViewController *regis;
}
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. NSArray *textArray = @[@"用户名",@"密码"];
NSArray *titles = @[@"注册",@"登录"];
CGFloat size = (self.view.frame.size.width-150)/2; for (int i=0; i<2; i++) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 100+80*i, 80, 50)];
label.text = textArray[i];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:24];
label.textColor = [UIColor redColor];
//label.backgroundColor = [UIColor whiteColor];
[self.view addSubview:label]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100+80*i, self.view.frame.size.width-120, 50)];
textField.borderStyle = UITextBorderStyleRoundedRect;
NSString *holder = [NSString stringWithFormat:@"请输入%@", textArray[i]];
textField.placeholder = holder;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.returnKeyType = UIReturnKeyDone;
textField.tag = 200+i;
textField.delegate = self;
[self.view addSubview:textField]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(50+i*(size+50), 400, size, 50);
//btn.backgroundColor = [UIColor cyanColor];
[btn setTitle:titles[i] forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:24]; btn.tag = 300+i;
[btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn];
} self.view.backgroundColor = [UIColor yellowColor];
} - (void)btnClicked:(UIButton *)btn
{
if (btn.tag == 300) {
//注册
regis = [[RegisterViewController alloc] init];
regis.delegate = self;//设置代理 // regis.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// [self presentViewController:regis animated:YES completion:nil]; [self.view addSubview:regis.view];
}
else if (btn.tag==301)
{
//登录
LoginViewController *login = [[LoginViewController alloc] init];
login.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:login animated:YES completion:nil];
}
}
#pragma mark ---SendDelegateReport--- - (void)sendName:(NSString *)name andPassword:(NSString *)password
{
UITextField *textField1 = (UITextField *)[self.view viewWithTag:200];
UITextField *textField2 = (UITextField *)[self.view viewWithTag:201];
textField1.text = name;
textField2.text = password;
} #pragma mark ---UITextFiledDelegate---
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
//隐藏键盘
[textField resignFirstResponder];
return YES;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
//
// RegProtocol.h
// UI4_注册登录界面
//
// Created by qianfeng on 15/7/4.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <Foundation/Foundation.h> @protocol SendDelegateReport <NSObject>
- (void)sendName:(NSString *)name andPassword:(NSString *)password;
@end
//
// RegisterViewController.h
// UI4_注册登录界面
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h>
#import "SendDelegateReport.h"
//制定协议
//@protocol SendDelegateReport <NSObject>
//
//- (void)sendName:(NSString *)name andPassword:(NSString *)password;
//
//@end @interface RegisterViewController : UIViewController <UITextFieldDelegate> @property (assign, nonatomic) id <SendDelegateReport>delegate; @end //
// RegisterViewController.m
// UI4_注册登录界面
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "RegisterViewController.h"
#import "ViewController.h"
@interface RegisterViewController ()
{
ViewController *v;
}
@end @implementation RegisterViewController - (void)viewDidLoad {
[super viewDidLoad];
v = [[ViewController alloc] init];
// Do any additional setup after loading the view.
NSArray *textArray = @[@"用户名",@"密码",@"邮箱"];
for (int i=0; i<3; i++) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 100+i*80, 80, 50)];
label.text = textArray[i];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont systemFontOfSize:24];
[self.view addSubview:label]; UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100+i*80, self.view.frame.size.width-120, 50)];
textField.borderStyle = UITextBorderStyleRoundedRect;
NSString *holder = [NSString stringWithFormat:@"请输入%@", textArray[i]];
textField.tag = 200+i;
textField.placeholder =holder;
textField.returnKeyType = UIReturnKeyDone;
textField.delegate = self;
[self.view addSubview:textField];
} CGFloat size = (self.view.frame.size.width-150)/2;
NSArray *titles = @[@"取消",@"保存"]; for (int i=0; i<2; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(50+(size+50)*i, 400, size, 50);
[btn setTitle:titles[i] forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:24];
btn.tag = 300+i;
[btn addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn];
} self.view.backgroundColor = [UIColor cyanColor];
} - (void)btnClicked:(UIButton *)btn
{
if (btn.tag==300) {
//取消
}
else if(btn.tag == 301)
{ //保存
SEL select = NSSelectorFromString(@"sendName:andPassword:"); // self.delegate = v;
if ([self.delegate respondsToSelector:select]) {
[self.delegate sendName:((UITextField *)[self.view viewWithTag:200]).text andPassword:((UITextField *)[self.view viewWithTag:201]).text];
}
}
//[self dismissViewControllerAnimated:YES completion:nil]; //[self presentViewController:v animated:YES completion:nil]; if([self.view superview])
{
[self.view removeFromSuperview];
}
} - (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
//
// LoginViewController.h
// UI4_注册登录界面
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import <UIKit/UIKit.h> @interface LoginViewController : UIViewController @end //
// LoginViewController.m
// UI4_注册登录界面
//
// Created by zhangxueming on 15/7/3.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "LoginViewController.h" @interface LoginViewController () @end @implementation LoginViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50,200, self.view.frame.size.width-100, 100)];
label.text = @"登录成功";
label.font = [UIFont italicSystemFontOfSize:35];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor redColor];
[self.view addSubview:label]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
btn.frame = CGRectMake(50, 400, self.view.frame.size.width-100, 50);
[btn setTitle:@"退出登录" forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:24];
[btn addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn]; self.view.backgroundColor = [UIColor greenColor];
} - (void)btnClicked
{
[self dismissViewControllerAnimated:YES completion:nil];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
UI4_注册登录界面的更多相关文章
- Android 比较好看的注册登录界面
各位看官姥爷: 对于一款android手机app而言,美观的界面使得用户有好的使用体验,而一款好看的注册登录界面也会给用户好的用户体验,那么话不多说,直接上代码 首先是一款简单的界面展示 1.登陆界面 ...
- RxSwift 实战操作【注册登录】
前言 看了前面的文章,相信很多同学还不知道RxSwift该怎么使用,这篇文件将带领大家一起写一个 注册登录(ps:本例子采用MVVM)的例子进行实战.本篇文章是基于RxSwift3.0写的,采用的是C ...
- vue2.0+koa2+mongodb实现注册登录
前言 前段时间和公司一个由技术转产品的同事探讨他的职业道路,对我说了一句深以为然的话: "不要把自己禁锢在某一个领域,技术到产品的转变,首先就是思维上的转变.你一直做前端,数据的交互你只知道 ...
- [课堂实践与项目]手机QQ客户端--4期(SQLite的加入,注册,找回,登录界面的修改):建立关于QQ注册类,使用SQLite进行存储,
经过昨天下午和今天上午的不懈努力,终于通过了SQLite的学习. 我们现在这里定义一个有关SQLIte的封装类,便于我在后面的用户注册,用户密码找回,和登录界面的使用 1.首先我们看看我们建立的use ...
- php注册、登录界面的制作
当初我觉得一个网站上注册和登录这两个功能很神奇,后来自己研究一下发现其实道理很简单,接下来看一下怎么实现的吧.... 我实在我的电脑上建了几个文件: login.html (登录页面) registe ...
- 注册表----修改Win7登录界面
在进行操作前,需要准备好背景图片.对背景图片的要求有三点: (1)图片必须是JPG格式: (2)必须将图片命名为backgroundDefault; (3)图片的体积必须小于256KB. 按下[Win ...
- Java登录界面的实现(注册、登录、背景图片)
*/ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.java * 作者:常轩 * 微信公众号:Worldh ...
- 一步步开发自己的博客 .NET版(3、注册登录功能)
前言 这次开发的博客主要功能或特点: 第一:可以兼容各终端,特别是手机端. 第二:到时会用到大量html5,炫啊. 第三:导入博客园的精华文章,并做分类.(不要封我) 第四:做 ...
- Android开发案例 - 注册登录
本文只涉及UI方面的内容, 如果您是希望了解非UI方面的访客, 请跳过此文. 在微博, 微信等App的注册登录过程中有这样的交互场景(如下图): 打开登录界面 在登录界面中, 点击注册, 跳转到注册界 ...
随机推荐
- 即时通信(RPC)的Rtmp实现--代码实现篇
实现的一般步骤是: step 1: 定义NetConnection对象连接rtmp,并监听NetStatusEvent.NET_STATUS事件 step 2: 在NetStatusEvent.NET ...
- spring mvc 3.0 ModelAndView模型视图类
见名知意,从名字上我们可以知道ModelAndView中的Model代表模型,View代表视图.即,这个类把要显示的数据存储到了Model属性中,要跳转的视图信息存储到了view属性.我们看一下Mod ...
- CSDN蒋涛:我为什么和王峰一起创办极客帮天使基金?
i 黑马 记者:王静静 7月15日,i黑马在一家咖啡厅见到了CSDN创始人蒋涛,这位中国最大的程序猿社区的创始人,正在经营一份新事业,他和蓝港在线创始人王峰正式成立了天使基金"极客 ...
- CENTOS YUM软件源
CentOS 7.0 使用 YUM 安装 MySQL 报错 问题现象 CentOS 7.0 使用 YUM 安装 MySQL 时出现类似如下错误信息: File contains no section ...
- Android实现数据存储技术
转载:Android实现数据存储技术 本文介绍Android中的5种数据存储方式. 数据存储在开发中是使用最频繁的,在这里主要介绍Android平台中实现数据存储的5种方式,分别是: 1 使用Shar ...
- 基于HTML5 SVG炫酷文字爆炸特效
这是一款使用html5 svg.css3和js制作的炫酷文字爆炸特效.该文字特效用SVG path属性将文字路径切割为很多小块,然后使用css3和js在鼠标滑过文字时制作文字爆炸分裂的炫酷效果. 在线 ...
- java中静态的代码块,静态变量,静态方法
简单了解一下java虚拟机--jvm几个内存区域: 方法区:在java的虚拟机中有一块专门用来存放已经加载的类信息.常量.静态变量以及方法代码的内存区域, 常量池:常量池是方法区的一部分,主要用来存放 ...
- Golang学习 - reflect 包
------------------------------------------------------------ 在 reflect 包中,主要通过两个函数 TypeOf() 和 ValueO ...
- jquery datatable[表格处理]
最近在公司实习发现一个额功能强大的表格解决方案,了解了一下,先总结如下: 1.官网:http://www.datatables.net/ 2.需要特别注意:被dataTable处理的table对象,必 ...
- 【阿里云产品评测】小站长眼中的巅峰云PK
[阿里云产品评测]小站长眼中的巅峰云PK 阿里云论坛用户:昵称-a5lianmeng 笔者是一名小站长,因狂热互联网,而在毕业后由宅男逐渐进入站长队伍,在毕业后的几年间,经营6个流量类网站,身为站长, ...