//
// 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. 能在你离开时照顾你的宠物的3D打印机器人

    您的宠物很可爱吧,您要离开时怎么办?找宠物公司来照顾他们?现在不用了.加拿大大学生推出了其3D打印的宠物机器人PetBot,它能照顾您的宠物,让您远程监控宠物,并能让您和宠物互动. “有 些人认为宠物 ...

  2. 关于THIS_FILE

    VC++中本身就有内存泄漏检查的机制,可以在向导生成的支持MFC的工程中看到如下代码:  #ifdef _DEBUG  #define new DEBUG_NEW  #undef THIS_FILE  ...

  3. IOS网络编程——第三方类库

    IOS网络编程——第三方类库 目录 概述 ASIHttpRequest AFNetworking 其他 概述 ASIHttpRequest AFNetworking 其他

  4. 解决Github使用Fastly CDN而导致不能加载网页的方法 转自 沙丘:http://www.enkoo.net/fastly-cdn-in-gifhub.html

    Github现在基本属于“安全”网站,但Github使用fastly.net的CDN服务后,其网站在国内经常不能正常加载网页.github.global.ssl.fastly.net的亚洲IP一般为1 ...

  5. Android点击Button实现功能的几种方法

          Android中Button控件应该算作是比较简单的控件,然而,它的使用频率却是非常的高,今天,我在这里总结了三种常用的点击Button实现其功能的方法.       1.很多时候,我们在 ...

  6. C# 制作透明窗体

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. 关键字提取算法之TF-IDF扫盲

    TF-IDF(term frequency–inverse document frequency)是一种用于资讯检索与资讯探勘的常用加权技术.TF-IDF是一种统计方法,用以评估一字词对于一个文件集或 ...

  8. [Java] MAP、LIST、SET集合解析

    在JAVA的util包中有两个所有集合的父接口Collection和Map,它们的父子关系: java.util        +Collection 这个接口extends自 --java.lang ...

  9. 【Android 界面效果17】Android手机平板两不误,使用Fragment实现兼容手机和平板的程序

    记得我之前参与开发过一个华为的项目,要求程序可以支持好几种终端设备,其中就包括Android手机和Android Pad.然后为了节省人力,公司无节操地让Android手机和Android Pad都由 ...

  10. C#中Dictionary小记

    使用C#中Dictionary的一下细节小记: 一.Dictionary.Add(key,value) 与 Dictionary[key]=value的区别: 如果Dictionary中已经有了key ...