//// AppDelegate.m// UI作业03//// Created by dllo on 15/7/31.// Copyright (c) 2015年 zhozhicheng. All rights reserved.//#import "AppDelegate.h"#import "LoginViewController.h"#import "RegistViewController.h"#import "PasswordViewController.h"@interfaceAppDelegate ()@end@implementationAppDelegate
-(void)dealloc
{
[_window self];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
//windows设置的根视图是LoginViewController
LoginViewController *loginVC = [[LoginViewController alloc] init];
self.window.rootViewController=loginVC;
[loginVC release];
returnYES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
//// LTView.h// UI作业03//// Created by dllo on 15/7/31.// Copyright (c) 2015年 zhozhicheng. All rights reserved.//#import <UIKit/UIKit.h>@interfaceLTView : UIView<UITextFieldDelegate>//两个对应的输入框@property(nonatomic,retain)UILabel *loadLabel1;
@property(nonatomic,retain)UILabel *loadLabel2;
@property(nonatomic,retain)UITextField *loadTextField1;
@property(nonatomic,retain)UITextField *loadTextField2;
@property(nonatomic,retain)UILabel *confirmLabel;
@property(nonatomic,retain)UILabel *numLabel;
@property(nonatomic,retain)UILabel *emailLabel;
@property(nonatomic,retain)UITextField *confirmTextField;
@property(nonatomic,retain)UITextField *numTextField;
@property(nonatomic,retain)UITextField *emailTextField;
@end
//// LoginViewController.m// UI作业03//// Created by dllo on 15/7/31.// Copyright (c) 2015年 zhozhicheng. All rights reserved.//#import "LoginViewController.h"#import "LTView.h"#import "RegistViewController.h"#import "PasswordViewController.h"@interfaceLoginViewController ()<UITextFieldDelegate,UIAlertViewDelegate>@property(nonatomic,retain)UILabel *textlabel;
@property(nonatomic,retain)UIAlertView *alertView;
@property(nonatomic,assign)BOOL isSelected;
@end@implementationLoginViewController
-(void)dealloc
{
[_alertView release];
[_textlabel release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.self.view.backgroundColor=[UIColor yellowColor];
//铺设登陆页面的魔化块//建立一个LTView视图
LTView *view1=[[LTView alloc] initWithFrame:CGRectMake(0, 0, 350, 500)];
[self.view addSubview:view1];
[view1 release];
//显示相应的文字
view1.loadLabel1.text=@"用户名";
view1.loadLabel2.text=@"密码";
view1.loadTextField1.placeholder=@"请输入账号";
view1.loadTextField2.placeholder=@"请输入密码";
view1.tag = 1000;
//密码隐藏
view1.loadTextField2.secureTextEntry=YES;
//全部清除按钮
view1.loadTextField1.clearButtonMode=UITextFieldViewModeAlways;
view1.loadTextField2.clearButtonMode=UITextFieldViewModeAlways;
//回收键盘的代理人
view1.loadTextField1.delegate=self;
view1.loadTextField2.delegate=self;
//铺设三个buttonUIButton *loadButton=[UIButton buttonWithType:UIButtonTypeSystem];
//BUTTON位置
loadButton.frame=CGRectMake(70, 300, 50, 25);
//button文字
[loadButton setTitle:@"登陆" forState:UIControlStateNormal];
[self.view addSubview:loadButton];
//设置button框,圆角
loadButton.layer.borderWidth=1;
loadButton.layer.cornerRadius=10;
//设置button方法
[loadButton addTarget:self action:@selector(loadClick:) forControlEvents:UIControlEventTouchUpInside];
UIButton *findButton=[UIButton buttonWithType:UIButtonTypeSystem];
findButton.frame=CGRectMake(150, 300, 70, 25);
[findButton setTitle:@"找回密码" forState:UIControlStateNormal];
[self.view addSubview:findButton];
findButton.layer.borderWidth=1;
findButton.layer.cornerRadius=10;
[findButton addTarget:self action:@selector(findClick:) forControlEvents:UIControlEventTouchUpInside];
UIButton *registerButton=[UIButton buttonWithType:UIButtonTypeSystem];
registerButton.frame=CGRectMake(250, 300, 50, 25);
[registerButton setTitle:@"注册" forState:UIControlStateNormal];
[self.view addSubview:registerButton];
registerButton.layer.borderWidth=1;
registerButton.layer.cornerRadius=10;
[registerButton addTarget:self action:@selector(registerClick:) forControlEvents:UIControlEventTouchUpInside];
//设置显示密码按钮图片的更换UIButton *picButton=[UIButton buttonWithType:UIButtonTypeCustom];
picButton.frame=CGRectMake(130,250, 30, 30);
[picButton setImage:[UIImage imageNamed:@"check.png" ] forState:UIControlStateNormal];
[self.view addSubview:picButton];
[picButton addTarget:self action:@selector(changeImage:) forControlEvents:UIControlEventTouchUpInside];
//文字 显示内容self.textlabel=[[UILabel alloc] initWithFrame:CGRectMake(180, 250, 150, 30)];
self.textlabel.text=@"显示内容";
[self.view addSubview:self.textlabel];
[self.textlabel release];
// 报错self.alertView=[[UIAlertView alloc] initWithTitle:@"报错" message:@"账号密码有误" delegate:self cancelButtonTitle:@"重新输入" otherButtonTitles:@"找回密码", nil];
}
//回收键盘的实现,之前需要签订协议
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
returnYES;
}
//图片显示内容切换,
-(void)changeImage:(UIButton *)picButton{
if (picButton.selected) {
//切换点击之后的两种图片状态
[picButton setImage:[UIImage imageNamed:@"check.png"] forState:UIControlStateNormal];
}else{
[picButton setImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
}
picButton.selected =!picButton.selected;
((LTView *)[self.view viewWithTag:1000]).loadTextField2.secureTextEntry ^= 1;
self.isSelected = !self.isSelected;
}
//判断账号密码的实现
-(void)loadClick:(UIButton *)loadButton
{
if ( ![((LTView *)[self.view viewWithTag:1000]).loadTextField1.text isEqualToString:@"1104010303"] || ![((LTView *)[self.view viewWithTag:1000]).loadTextField2.text isEqualToString:@"920928"]) {
[self.alertView show];
}
}
-(void)findClick:(UIButton *)findButton
{
RegistViewController *registVC=[[RegistViewController alloc] init];
[registVC setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:registVC animated:YES completion:^{
}];
[registVC release];
}
-(void)registerClick:(UIButton *)registerButton
{
PasswordViewController *passWordVC=[[PasswordViewController alloc] init];
[passWordVC setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:passWordVC animated:YES completion:^{
}];
// [passWordVC release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
RegistViewController *registVC = [[RegistViewController alloc] init];
[registVC setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:registVC animated:YES completion:^{
}];
}
}
- (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
//// RegistViewController.m// UI作业03//// Created by dllo on 15/7/31.// Copyright (c) 2015年 zhozhicheng. All rights reserved.//#import "RegistViewController.h"@interfaceRegistViewController ()<UITextFieldDelegate>@property(nonatomic,retain)UITextField *emailTextField;
@end@implementationRegistViewController
-(void)dealloc
{
[_emailTextField release];
[super dealloc];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.//当前页面背景self.view.backgroundColor=[UIColor cyanColor];
//建立email输入框self.emailTextField=[[UITextField alloc] initWithFrame:CGRectMake(100, 200, 200, 40)];
[self.view addSubview:self.emailTextField];
self.emailTextField.layer.borderWidth=1;
self.emailTextField.layer.cornerRadius=10;
self.emailTextField.placeholder=@"电子邮箱";
//建立此页面的两个buttonUIButton *findButton=[UIButton buttonWithType:UIButtonTypeSystem];
findButton.frame=CGRectMake(120, 280, 40, 25);
[findButton setTitle:@"找回" forState:UIControlStateNormal];
[self.view addSubview:findButton];
findButton.layer.borderWidth=1;
findButton.layer.cornerRadius=10;
[findButton addTarget:self action:@selector(findClick:) forControlEvents:UIControlEventTouchUpInside];
UIButton *abolishButton=[UIButton buttonWithType:UIButtonTypeSystem];
abolishButton.frame=CGRectMake(200, 280, 40, 25);
[abolishButton setTitle:@"取消" forState:UIControlStateNormal];
[self.view addSubview:abolishButton];
abolishButton.layer.borderWidth=1;
abolishButton.layer.cornerRadius=10;
[abolishButton addTarget:self action:@selector(abolishClick:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)abolishClick:(UIButton *)button
{
[self dismissViewControllerAnimated:YES completion:^{
}];
}
-(void)findClick:(UIButton *)findButton
{
}
- (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