//// 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