//
// 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. Mysql命令alter add:增加表的字段

    alter add命令用来增加表的字段. alter add命令格式:alter table 表名 add字段 类型 其他; 例如,在表MyClass中添加了一个字段passtest,类型为int(4 ...

  2. TP常用函数

    英文字符可用形如 {$vo.title|substr=0,5} 如果是中文字符thinkphp提供了msubstr如下 function msubstr($str, $start=0, $length ...

  3. crm2011创建货币Money类型的字段

    using System;     using Microsoft.Xrm.Sdk;     using Microsoft.Xrm.Sdk.Messages;     using Microsoft ...

  4. cocos2dx-jsb 跨语言调用及第三方集成 - 过程记录

    1:C++中调用js方法: 问题:ios中当用户通过home键将游戏转入后台时,调用js中的暂停游戏方法: AppDelegate::applicationDidEnterBackground() 和 ...

  5. ios中@class和 #import,两种方式的讨论

    转自:http://blog.sina.com.cn/s/blog_a843a8850101b6a7.html 很多刚开始学习iOS开发的同学可能在看别人的代码的时候会发现有部分#import操作写在 ...

  6. 淘宝Refrash_token签名错误的解决办法

    最近在做淘宝相关应用,想要通过Refrash_token来延长SessionKey的授权时间,但是总是报406 sign error. 经过多次尝试和多方询问,方才知道原来淘宝给的.net SDK里面 ...

  7. 通过uiview动画来放大图片

    UIImage *image=[UIImage imageNamed:"]; UIImageView *imageView=[[UIImageView alloc]init]; imageV ...

  8. Java优先级队列

    package com.lk.A; import java.util.PriorityQueue; public class Test5 { public static void main(Strin ...

  9. Linux Bash Shell学习笔记

    参数扩展: 1.被名称引用的参数称作变量2.被数字引用的参数称作位置参数3.被特定符号引用的参数具有特殊的含义和用途,被称作Bash的特殊内部变量引用. 基本参数扩展:字符$会引导参数扩展.大括号是可 ...

  10. 转:鏖战双十一-阿里直播平台面临的技术挑战(webSocket, 敏感词过滤等很不错)

    转自:http://www.infoq.com/cn/articles/alibaba-broadcast-platform-technology-challenges 鏖战双十一-阿里直播平台面临的 ...