[Code Note] account, password, and code note

Source: Internet
Author: User

[Code Note] account, password, and code note

I ,.

 

 

 

2. Engineering Drawing.

3. Code.

RegisViewController. h

#import <UIKit/UIKit.h>@interface RegisViewController : UIViewController@end

 

RegisViewController. m

// Registration page # 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 = @ "register"; [self initView];}-(void) initView {accountField = [[UITextField alloc] initWithFrame: CGRectMake (50,100,200, 40)]; [accountField setBackgroundColor: [UIColor redColor]; [accountField setPlaceholder: @ "enter an account"]; [accountField setKeyboardType: UIKeyboardTypeNumberPad]; [accountField setClearsContextBef OreDrawing: YES]; [self. view addSubview: accountField]; passField = [[UITextField alloc] initWithFrame: CGRectMake (50,160,200, 40)]; [passField setBackgroundColor: [UIColor redColor]; [passField setPlaceholder: @ "Enter Password"]; [passField setKeyboardType: UIKeyboardTypeNumberPad]; [passField setClearsContextBeforeDrawing: YES]; [self. view addSubview: passField]; UIButton * registeBut = [UIButton buttonWithType: UIB UttonTypeRoundedRect]; registeBut. backgroundColor = [UIColor greenColor]; registeBut. frame = CGRectMake (70,220,100, 40); [registeBut setTitle: @ "register" forState: UIControlStateNormal]; [registeBut addTarget: self action: @ selector (resis) forControlEvents: UIControlEventTouchUpInside]; [self. view addSubview: registeBut];} // when registering, save the account and password to the local device. -(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 didreceivemorywarning]; // Dispose of any resources that can be recreated .}

 

LoginViewController. h

#import <UIKit/UIKit.h>@interface LoginViewController : UIViewController@end

 

LoginViewController. m

// Login page # import "LoginViewController. h "@ class RegisViewController; @ interface LoginViewController () {UITextField * accountField; UITextField * passField;} @ end @ implementation LoginViewController-(id) initWithNibName :( NSString *) nibNameOrNil bundle :( NSBundle *) handle {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 = @ "login"; [self initView];}-(void) initView {accountField = [[UITextField alloc] initWithFrame: CGRectMake (50,100,200, 40)]; [accountField setBackgroundColor: [UIColor redColor]; [accountField setKeyboardType: UIKeyboardTypeNumberPad]; [accountField Expiration: 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: @ "login" forState: UIControlStateNormal]; [loginBut addTarget: self action: @ selector (login) forControlEvents: UIControlEventTouchUpInside]; [self. view addSubview: loginBut];}-(void) login {[self. navigationController popViewControllerAnimated: YES];}

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.