黑马程序员——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
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 讲解iOS开发中基本的定位功能实现
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- 浅析iOS应用开发中线程间的通信与线程安全问题
- 检测iOS设备是否越狱的方法
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?
- Android、iOS和Windows Phone中的推送技术详解
- IOS 改变键盘颜色代码
- 举例详解iOS开发过程中的沙盒机制与文件
- Android和IOS的浏览器中检测是否安装某个客户端的方法
- 分享一个iOS下实现基本绘画板功能的简单方法
- javascript实现阻止iOS APP中的链接打开Safari浏览器