您的位置:首页 > 职场人生

黑马程序员——iOS 开发学习---控件制作登录注册页面

2016-01-11 20:57 661 查看
——Java培训、Android培训、iOS培训、.Net培训、期待与您交流! ——-

AppDelegate.m

#import "AppDelegate.h"
#import "FirstViewController.h"
@implementation AppDelegate

- (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];
//创建要现实的视图控制器的对象
FirstViewController *fistVC=[[FirstViewController alloc]init];
self.window.rootViewController=fistVC;
//赋值给window的跟试图控制器
return YES;
}


FirstViewController.m

#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "AppDelegate.h"
@interface FirstViewController ()

@end

@implementation FirstViewController

- (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 from its nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)goToRegist:(UIButton *)sender {
//跳转到登陆页面
//创建要跳转页面的对象
SecondViewController *secondVC=[[SecondViewController alloc]init];
//应用程序对象
UIApplication* application=[UIApplication sharedApplication];
//入口类对象
AppDelegate *appDelegate=application.delegate;
//主window
UIWindow* window=appDelegate.window;
window.rootViewController=secondVC;

//新建跳转动画(UIView动画)
//一般参数先写nil nil
[UIView beginAnimations:nil context:nil];//开始动画
[UIView setAnimationDuration:0.5];//设置动画时间(s)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES]; //动画样式(翻转类型)1.是一个枚举把所有的动画样式都给你
//2.给谁做动画(瞬时动作 写他们的父视图;延时动画 写自己)
//3.设置缓存(YES)
[UIView commitAnimations];//结束(提交)动画

//赋值给window的跟试图控制器

}
- (IBAction)enterPersonalCenter:(UIButton *)sender {
ThirdViewController *thirdVC=[[ThirdViewController alloc]init];
UIApplication* application=[UIApplication sharedApplication];
//入口类对象
AppDelegate *appDelegate=application.delegate;
//主window
UIWindow* window=appDelegate.window;
window.rootViewController=thirdVC;

//新建跳转动画(UIView动画)
//一般参数先写nil nil
[UIView beginAnimations:nil context:nil];//开始动画
[UIView setAnimationDuration:0.5];//设置动画时间(s)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES]; //动画样式(翻转类型)1.是一个枚举把所有的动画样式都给你
//2.给谁做动画(瞬时动作 写他们的父视图;延时动画 写自己)
//3.设置缓存(YES)
[UIView commitAnimations];//结束(提交)动画

//赋值给window的跟试图控制器

}

//点击空白收起键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
}
@end


SecondViewController.m

#import "SecondViewController.h"
#import "FirstViewController.h"
#import "AppDelegate.h"
#define K_ALERTVIEW(_message_) UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:_message_ delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];   \   //换行连接符
[alertView show];//展示提醒栏
@interface SecondViewController ()

@end

@implementation SecondViewController

- (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 from its nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)returnEnter:(UIButton *)sender {
FirstViewController *firetVC=[[FirstViewController alloc]init];
//应用程序对象
UIApplication* application=[UIApplication sharedApplication];
//入口类对象
AppDelegate *appDelegate=application.delegate;
//主window
UIWindow* window=appDelegate.window;
window.rootViewController=firetVC;

//新建跳转动画(UIView动画)
//一般参数先写nil nil
[UIView beginAnimations:nil context:nil];//开始动画
[UIView setAnimationDuration:0.5];//设置动画时间(s)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:window cache:YES]; //动画样式(翻转类型)1.是一个枚举把所有的动画样式都给你
//2.给谁做动画(瞬时动作 写他们的父视图;延时动画 写自己)
//3.设置缓存(YES)
[UIView commitAnimations];//结束(提交)动画

//赋值给window的跟试图控制器
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
}
- (void)dealloc {
[text_psw release];
[text_psw1 release];
[text_name release];
[text_number release];
[super dealloc];
}
- (IBAction)Resign:(UIButton *)sender {
if (text_name.text.length != 0 && text_number.text.length != 0 && text_psw != 0&&text_psw1.text.length != 0 )
{
//NSLog(@"不为空");
//密码和确认密码是否一致
if ([text_psw.text isEqualToString:text_psw1.text])
{
//一致,注册成功,直接跳回登陆页面
K_ALERTVIEW(@"注册成功,请返回登陆页登陆")
[self.view endEditing:YES];
}else
{
//密码和确认密码不一致
K_ALERTVIEW(@"密码和确认密码不一致")
}
}else
{
//警告框:UIAlertView
//title:标题  message:提示的信息  delegate:nil  cancel:取消按钮标题  other:其他按钮标题
K_ALERTVIEW(@"所有输入不能为空")
}

}
@end


ThirdViewController.m

#import "ThirdViewController.h"
#import "FirstViewController.h"
#import "AppDelegate.h"
@interface ThirdViewController ()

@end

@implementation ThirdViewController

- (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 from its nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Exit:(UIButton *)sender {
FirstViewController *firetVC=[[FirstViewController alloc]init];
//应用程序对象
UIApplication* application=[UIApplication sharedApplication];
//入口类对象
AppDelegate *appDelegate=application.delegate;
//主window
UIWindow* window=appDelegate.window;
window.rootViewController=firetVC;

//新建跳转动画(UIView动画)
//一般参数先写nil nil
[UIView beginAnimations:nil context:nil];//开始动画
[UIView setAnimationDuration:0.5];//设置动画时间(s)
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:window cache:YES]; //动画样式(翻转类型)1.是一个枚举把所有的动画样式都给你
//2.给谁做动画(瞬时动作 写他们的父视图;延时动画 写自己)
//3.设置缓存(YES)
[UIView commitAnimations];//结束(提交)动画

//赋值给window的跟试图控制器
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios 黑马程序员