一,效果图。

二,工程图。

三,代码。

RegisViewController.h

#import <UIKit/UIKit.h>

@interface RegisViewController : UIViewController

@end

RegisViewController.m

//注册页面
#import "RegisViewController.h"
#import "LoginViewController.h" @interface RegisViewController ()
{
UITextField *accountField;
UITextField *passField;
} @end @implementation RegisViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. self.title=@"注册"; [self initView]; }
-(void)initView
{
accountField=[[UITextField alloc]initWithFrame:CGRectMake(50, 100, 200, 40)];
[accountField setBackgroundColor:[UIColor redColor]];
[accountField setPlaceholder:@"请输入账号"];
[accountField setKeyboardType:UIKeyboardTypeNumberPad];
[accountField setClearsContextBeforeDrawing:YES];
[self.view addSubview:accountField]; passField=[[UITextField alloc]initWithFrame:CGRectMake(50, 160, 200, 40)];
[passField setBackgroundColor:[UIColor redColor]];
[passField setPlaceholder:@"请输入密码"];
[passField setKeyboardType:UIKeyboardTypeNumberPad];
[passField setClearsContextBeforeDrawing:YES];
[self.view addSubview:passField]; UIButton *registeBut=[UIButton buttonWithType:UIButtonTypeRoundedRect];
registeBut.backgroundColor=[UIColor greenColor];
registeBut.frame=CGRectMake(70, 220, 100, 40);
[registeBut setTitle:@"注册" forState:UIControlStateNormal];
[registeBut addTarget:self action:@selector(resis) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:registeBut]; } //注册的时候,将账号,密码保存到本地。
-(void)resis
{ NSUserDefaults *defaut=[NSUserDefaults standardUserDefaults];
[defaut setObject:accountField.text forKey:@"account"];
[defaut setObject:passField.text forKey:@"password"];
[defaut synchronize]; LoginViewController *login=[[LoginViewController alloc]init];
[self.navigationController pushViewController:login animated:YES]; }
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

LoginViewController.h

#import <UIKit/UIKit.h>

@interface LoginViewController : UIViewController

@end

LoginViewController.m

//登陆页面
#import "LoginViewController.h" @class RegisViewController;
@interface LoginViewController ()
{
UITextField *accountField;
UITextField *passField;
}
@end @implementation LoginViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title=@"登陆"; [self initView]; }
-(void)initView
{
accountField=[[UITextField alloc]initWithFrame:CGRectMake(50, 100, 200, 40)];
[accountField setBackgroundColor:[UIColor redColor]];
[accountField setKeyboardType:UIKeyboardTypeNumberPad];
[accountField setClearsContextBeforeDrawing:YES];
[accountField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"account"]];
[self.view addSubview:accountField]; passField=[[UITextField alloc]initWithFrame:CGRectMake(50, 160, 200, 40)];
[passField setBackgroundColor:[UIColor redColor]];
[passField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"password"]];
[passField setKeyboardType:UIKeyboardTypeNumberPad];
[passField setClearsContextBeforeDrawing:YES];
[self.view addSubview:passField]; UIButton *loginBut=[UIButton buttonWithType:UIButtonTypeRoundedRect];
loginBut.backgroundColor=[UIColor greenColor];
loginBut.frame=CGRectMake(70, 220, 100, 40);
[loginBut setTitle:@"登陆" forState:UIControlStateNormal];
[loginBut addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:loginBut]; }
-(void)login
{
[self.navigationController popViewControllerAnimated:YES];
}
 
 

【代码笔记】iOS-账号,密码记住的更多相关文章

  1. 【代码笔记】iOS-给密码进行加密

    一,工程图. 二,代码. #import "ViewController.h" #import "Base64CodeByteFunc.h" @interfac ...

  2. 通过游戏学python 3.6 第一季 第五章 实例项目 猜数字游戏--核心代码--猜测次数--随机函数和屏蔽错误代码--优化代码及注释--简单账号密码登陆 可复制直接使用 娱乐 可封装 函数

    #猜数字--核心代码--猜测次数--随机函数和屏蔽错误代码---优化代码及注释--账号密码登陆 #!usr/bin/env python #-*-coding:utf-8-*- #QQ12411129 ...

  3. C# ASP.NET MVC:使用Cookie记住账号密码

    MVC记住账号密码 使用cookie操作 前端: <div> 用户名:<input type="text" id="UserName" val ...

  4. 利用SharedPreferences完成记住账号密码的功能

    利用SharedPreferences完成记住账号密码的功能 效果图: 记住密码后,再次登录就会出现账号密码,否则没有. 分析: SharedPreferences可将数据存储到本地的配置文件中 Sh ...

  5. css 修改placeholder字体颜色字体大小 修改input记住账号密码后的默认背景色

     壹 ❀ 引 本来这个阶段的项目页面都是给实习生妹子做的,我只用写写功能接接数据,但这两天妹子要忙翻译,这个工作阶段也快结束了导致有点慌,只能自己把剩余的几个小页面给写了. 那么做页面的过程中,UI也 ...

  6. struts2的记住账号密码的登录设计

    一个简单的基于struts2的登录功能,实现的额外功能有记住账号密码,登录错误提示.这里写上我在设计时的思路流程,希望大家能给点建设性的意见,帮助我改善设计. 登录功能的制作,首先将jsp界面搭建出来 ...

  7. cocos2d JS 本地缓存存储登陆记住账号密码->相当于C++中的UserDefault

    在cocos-js 3.0以上的版本中,当我们用到本地存储的时候,发现以前用到的UserDefault在JS中并没有导出,而是换成了LocalStorage. 在LocalStorage.h文件中我们 ...

  8. git小乌龟工具TortoiseGit记住你的账号密码

    在使用TortoiseGit的过程中,发下每次push或者pull都要重复输入账号密码,非常麻烦 怎么设置记住密码 在[系统盘]:\Users[你的用户名](比如C:\User\Administrat ...

  9. Linux让git记住账号密码

    Linux让git记住账号密码 ——IT唐伯虎 摘要: Linux让git记住账号密码. 1.进入根目录,指令:cd / 2.创建记录账号密码的文件,指令:touch .git-credentials ...

  10. 如何让git小乌龟工具TortoiseGit记住你的账号密码

    在使用小乌龟的过程中,发下每次push或者pull都要重复输入账号密码,非常麻烦. 如果能记住账号密码就好了,这样就省去了时间. 怎么设置记住密码 在[系统盘]:\Users[你的用户名]下面,有一个 ...

随机推荐

  1. CentOS上 Mono 3.2.8运行ASP.NET MVC4经验

    周一到周三,折腾了两天半的时间,经历几次周折,在小蝶惊鸿的鼎力帮助下,终于在Mono 3.2.8上运行成功MVC4.在此总结经验如下: 系统平台的版本: CentOS 6.5 Mono 3.2.8 J ...

  2. 绿色版的Linux.NET——“Jws.Mono”(续)

    在前一篇文章中,我们简略的介绍了jws.mono的安装使用,以及我们如何自己动手做一个jws.mono出来. 在文章发表之后的几天里,我一直觉得有点不妥之处,直到后来猛然的意识到:我们自己动手做的jw ...

  3. [PHP源码阅读]empty和isset函数

    近日被问到PHP中empty和isset函数时怎么判断变量的,刚开始我是一脸懵逼的,因为我自己也只是一知半解,为了弄懂其真正的原理,赶紧翻开源码研究研究.经过分析可发现两个函数调用的都是同一个函数,因 ...

  4. [翻译]AKKA笔记 -ACTOR SUPERVISION - 8

    失败更像是分布式系统的一个特性.因此Akka用一个容忍失败的模型,在你的业务逻辑与失败处理逻辑(supervision逻辑)中间你能有一个清晰的边界.只需要一点点工作,这很赞.这就是我们要讨论的主题. ...

  5. SSH框架整合(代码加文字解释)

    一.创建数据库并设置编码. A) create database oa default character set utf8. 二.MyEclipse工程 A) 在Myeclipse里创建web工程, ...

  6. Cleaver快速制作网页PPT

    原文首发链接:http://www.jeffjade.com/2015/10/15/2015-10-16-cleaver-make-ppt/ 写在开始之前 互联网时代,以浏览器作为入口,已经有越来越多 ...

  7. mongoose - 让node.js高效操作mongodb

    Mongoose库简而言之就是在node环境中操作MongoDB数据库的一种便捷的封装,一种对象模型工具,类似ORM,Mongoose将数据库中的数据转换为JavaScript对象以供你在应用中使用. ...

  8. Maven在Eclipse中的实用小技巧

    前言     我们在开发的工程中很多都是Maven项目,这样更加便于我们jar包的管理.而我们一般使用的IDE都是Eclipse,由于我们在日常的开发过程中会经常要用到一些Maven的操作,所以我今天 ...

  9. php json_encode数据格式化

    在用ajax与后台交互数据的时候,后台传回来的数据格式不正确,后参考@傲雪星枫的博客在PHP文件添加了一段代码 :echo json_encode($arr); 成功解决.

  10. jQuery-template.js学习

    花了点时间,看了下jQuery-template.js,不多废话,先上结构 jQuery.each({..},function(){}) jQuery.fn.extend({..}) jQuery.e ...