一,效果图。

二,工程图。

三,代码。

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. ES6 箭头函数中的 this?你可能想多了(翻译)

    箭头函数=>无疑是ES6中最受关注的一个新特性了,通过它可以简写 function 函数表达式,你也可以在各种提及箭头函数的地方看到这样的观点——“=> 就是一个新的 function”. ...

  2. 微信硬件H5面板开发(二) ---- 实现一个灯的控制

    在第一节中讲解了openApi的调用,这一篇讲一下如何实现一个灯的控制.就用微信提供的lamp例子来做,将代码扒下来(实在是没办法,没有示例),整合到自己的项目中.lamp源码:http://file ...

  3. C++ std::forward_list

    std::forward_list template < class T, class Alloc = allocator > class forward_list; Forward li ...

  4. Atitit 输入法原理与概论ati use

    Atitit 输入法原理与概论ati use 1.1. 输入法技术点1 1.2. 参考多多输入法设置2 1.3. Attilax博客集合知识点2 1.4. 输入法的书籍当当几乎没有..都是打字的.2 ...

  5. Bucket不为空,请检查该Bucket是否包含未删除的Object或者未成功的Multipart碎片

    异常处理汇总 ~ 修正果带着你的Net飞奔吧!http://www.cnblogs.com/dunitian/p/4599258.html 图示解决==>详细如下:

  6. SQL Server系列目录

    一.SQL Server基础部分 1  数据库概念及规范化设计 1.1 数据库物理模式设计 1.2 Microsoft SQL Server Management Studio模板资源管理器 2 数据 ...

  7. 【Win 10 应用开发】获取本机的IP地址

    按照老规矩,也是朋友的建议,老周今天在吹牛之前,先讲一个小故事. 有朋友问我,老周,你现在还发短信吗,你每个月用多少电话费?唉,实话说,现在真的发短信不多了,套餐送的130条短信,每月都发不了一条.至 ...

  8. Javascript的二进制数据处理学习 ——nodejs环境和浏览器环境分别分析

    以前用JavaScript主要是处理常规的数字.字符串.数组对象等数据,基本没有试过用JavaScript处理二进制数据块,最近的项目中涉及到这方面的东西,就花一段时间学了下这方面的API,在此总结一 ...

  9. AFNetworking 3.0 源码解读(三)之 AFURLRequestSerialization

    这篇就讲到了跟请求相关的类了 关于AFNetworking 3.0 源码解读 的文章篇幅都会很长,因为不仅仅要把代码进行详细的的解释,还会大概讲解和代码相关的知识点. 上半篇: URI编码的知识 关于 ...

  10. 用Middleware给ASP.NET Core Web API添加自己的授权验证

    Web API,是一个能让前后端分离.解放前后端生产力的好东西.不过大部分公司应该都没能做到完全的前后端分离.API的实现方式有很 多,可以用ASP.NET Core.也可以用ASP.NET Web ...