//
// 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_注册登录界面的更多相关文章

  1. Android 比较好看的注册登录界面

    各位看官姥爷: 对于一款android手机app而言,美观的界面使得用户有好的使用体验,而一款好看的注册登录界面也会给用户好的用户体验,那么话不多说,直接上代码 首先是一款简单的界面展示 1.登陆界面 ...

  2. RxSwift 实战操作【注册登录】

    前言 看了前面的文章,相信很多同学还不知道RxSwift该怎么使用,这篇文件将带领大家一起写一个 注册登录(ps:本例子采用MVVM)的例子进行实战.本篇文章是基于RxSwift3.0写的,采用的是C ...

  3. vue2.0+koa2+mongodb实现注册登录

    前言 前段时间和公司一个由技术转产品的同事探讨他的职业道路,对我说了一句深以为然的话: "不要把自己禁锢在某一个领域,技术到产品的转变,首先就是思维上的转变.你一直做前端,数据的交互你只知道 ...

  4. [课堂实践与项目]手机QQ客户端--4期(SQLite的加入,注册,找回,登录界面的修改):建立关于QQ注册类,使用SQLite进行存储,

    经过昨天下午和今天上午的不懈努力,终于通过了SQLite的学习. 我们现在这里定义一个有关SQLIte的封装类,便于我在后面的用户注册,用户密码找回,和登录界面的使用 1.首先我们看看我们建立的use ...

  5. php注册、登录界面的制作

    当初我觉得一个网站上注册和登录这两个功能很神奇,后来自己研究一下发现其实道理很简单,接下来看一下怎么实现的吧.... 我实在我的电脑上建了几个文件: login.html (登录页面) registe ...

  6. 注册表----修改Win7登录界面

    在进行操作前,需要准备好背景图片.对背景图片的要求有三点: (1)图片必须是JPG格式: (2)必须将图片命名为backgroundDefault; (3)图片的体积必须小于256KB. 按下[Win ...

  7. Java登录界面的实现(注册、登录、背景图片)

    */ * Copyright (c) 2016,烟台大学计算机与控制工程学院 * All rights reserved. * 文件名:text.java * 作者:常轩 * 微信公众号:Worldh ...

  8. 一步步开发自己的博客 .NET版(3、注册登录功能)

    前言 这次开发的博客主要功能或特点:    第一:可以兼容各终端,特别是手机端.    第二:到时会用到大量html5,炫啊.    第三:导入博客园的精华文章,并做分类.(不要封我)    第四:做 ...

  9. Android开发案例 - 注册登录

    本文只涉及UI方面的内容, 如果您是希望了解非UI方面的访客, 请跳过此文. 在微博, 微信等App的注册登录过程中有这样的交互场景(如下图): 打开登录界面 在登录界面中, 点击注册, 跳转到注册界 ...

随机推荐

  1. WCF入门教程(二)从零做起

    通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK默认创建的样本 1.创建WCF服务库 2.看其生成结构 1)IService1.cs(协议) 定义了协议,具体什么操作,操作的参数和返回值 ...

  2. java.net.SocketException四大异常解决方案【转】

    java.net.SocketException如何才能更好的使用呢?这个就需要我们先要了解有关这个语言的相关问题.希望大家有所帮助.那么我们就来看看有关java.net.SocketExceptio ...

  3. WPF 之 WPF应用程序事件

    当新建一个wpf应用程序,会自动生成一个App.xaml和MainWindow.xaml文件. 其中 App.xam 用来设置Application,应用程序的起始文件和资源及应用程序的一些属性和事件 ...

  4. C. Tavas and Karafs 二分查找+贪心

    C. Tavas and Karafs #include <iostream> #include <cstdio> #include <cstring> #incl ...

  5. encodeURIComponent() 和 encodeURI()

    encodeURI(URIstring): 该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ' ( ) . 该方法的目的是对 URI ...

  6. Java开发核心技术面试心得分析

    Java的数据结构有哪些?Map与Set的本质区别是什么? 分析:Java常见的数据结构有Collection和Map,其中Collection接口下包括List和Set接口,其下又有多个实现类如Li ...

  7. 【阿里云产品公测】在Laravel4框架中使用阿里云ACE的缓存服务

    作者:阿里云用户dvbhack 受论坛排版和格式限制,这篇帖子的格式不是很利于阅读,如果你看帖子觉得不那么舒服,可以看我发表在自己博客上的原文:http://www.ofcss.com/2014/04 ...

  8. 【Linux/Ubuntu学习2】ubuntu-ubuntu10.04使用wine安装SourceInsight

    1. 环境:ubuntu10.04 2. 安装 wine 关于 wine ,请参考这里.通过网络安装: $ sudo apt-get install wine 3. 安装 SourceInsight ...

  9. (六)u-boot2013.01.01 for TQ210:《精简u-boot文件目录,定制自己的目标板》

    1. 删改U-boot代码结构 把不用到的和与我们s5pv210移植无关的硬件平台代码统统删除,眼不见为净.这样代码看起来就干净利落多了. 1.1.进入arch目录,删掉除arm以外的目录 处理前: ...

  10. (三)u-boot2013.01.01 for TQ210:《mkconfig分析》

    /* 和分析makefile一样,分析mkconfig同样注重句法分析 */ ############################################################# ...