一,效果图。

二,工程图。

三,代码。

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. [DeviceOne开发]-土地销售项目源码分享

    一.简介 这个是一个真实项目开源,虽然不是很花哨,但是中规中矩,小细节处理的也很好,非常值得参考和借鉴.里面的数据都缓存到本地,可以离线运行,但是调整一下代码,马上就可以和服务端完全对接.后续会有详细 ...

  2. java中文乱码解决之道(九)-----总结

    乱码,我们前台展示的杀手,可能有些朋友和我的经历一样:遇到乱码先按照自己的经验来解决,如果没有解决就google,运气好一搜就可以解决,运气不好可能够你折腾一番了.LZ之所以写这个系列博客就是因为遇到 ...

  3. C#非常重要基础之多态

    前几天看了一位同志的博客,写的是关于他自己去支付宝面试的经历.过程大体是这样的:问答的时候,前面部分,作者都应答如流,说起自己经验如何之丰富,最后面试官问了作者一个问题:请简述多态的概念和作用.结果这 ...

  4. iOS App引导页功能实现

    一.写作原因 以前都没有想着来写点东西,今天遇到件事情让我决定每次还是要做记录.因为以前自己可以轻松的完成pod spec的配置,但是今天在做的时候还是忘了遇到了很多坑.pod spec配置遇到的坑不 ...

  5. C#设计模式-备忘录模式

    访问者模式的实现是把作用于某种数据结构上的操作封装到访问者中,使得操作和数据结构隔离.而本文要介绍的备忘者模式与命令模式有点相似,不同的是,命令模式保存的是发起人的具体命令(命令对应的是行为),而备忘 ...

  6. EXISTS 引入子查询时,在选择列表中只能指定一个表达式

  7. 锋利的jQuery--表单等(读书笔记三)

    1.input元素中的多选的,单选,不选,涉及属性checked   2.select元素中的选中,涉及selected   3.表单的验证   4.表格隔行变色 $("tr:odd&quo ...

  8. TextView使用大全

    最近打算写一个系列的android初级开发教程,预计40篇以上的文章,结合我实际工作中的经验,写一些工作中经常用到的技术,让初学者可以少走弯路,写一个系列的话,大家学习起来也有头有尾. 今天就从我们每 ...

  9. AFNetworking 3.0 源码解读(四)之 AFURLResponseSerialization

    本篇是AFNetworking 3.0 源码解读的第四篇了. AFNetworking 3.0 源码解读(一)之 AFNetworkReachabilityManager AFNetworking 3 ...

  10. URI编码解码和base64

    概述 对于uri的编解码,在js中有3对函数,分别是escape/unescape,encodeURI/decodeURI,encodeURIComponent/decodeURIComponent. ...