用导航控制器制作一个简单的登陆显示

简介:

用导航控制器制作一个简单的登陆显示

1.Empty项目的创建+AppDelegate的修改

#import "DXWAppDelegate.h" #import "LoginViewController.h" @implementation DXWAppDelegate  - (void)dealloc {     [_window release];     [super dealloc]; }  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];     //创建首页     LoginViewController *first = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];     //创建一个导航栏,其中的首页是FirstViewController     UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:first];     //将导航栏作为根视图控制器     self.window.rootViewController  = nav;     [first release];     self.window.backgroundColor = [UIColor whiteColor];     [self.window makeKeyAndVisible];     return YES; } 

2.登陆视图的制作,命名为LoginViewController,带有xib文件


LoginViewController.h:

#import <UIKit/UIKit.h>  @interface LoginViewController : UIViewController @property (retain, nonatomic) IBOutlet UITextField *ttbName; @property (retain, nonatomic) IBOutlet UITextField *ttbPassword; - (IBAction)ttbLogin:(id)sender; - (IBAction)ttbCancel:(id)sender; - (IBAction)resign:(id)sender; @end

LoginViewController.m:

#import "LoginViewController.h" #import "ReturnViewController.h" @interface LoginViewController ()  @end  @implementation LoginViewController  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];     if (self) { //        [self.navigationController setNavigationBarHidden:YES animated:YES];     }     return self; }  -(void)viewWillAppear:(BOOL)animated {     self.ttbName.text = @"";     self.ttbPassword.text = @"";     [self.navigationController setNavigationBarHidden:YES animated:YES]; }  - (void)viewDidLoad {     [super viewDidLoad];      }  - (void)didReceiveMemoryWarning {     [super didReceiveMemoryWarning];     // Dispose of any resources that can be recreated. }  - (void)dealloc {     [_ttbName release];     [_ttbPassword release];     [super dealloc]; } - (IBAction)ttbLogin:(id)sender {     [self.ttbName resignFirstResponder];     [self.ttbPassword resignFirstResponder];     ReturnViewController *sec = [[ReturnViewController alloc] initWithNibName:@"ReturnViewController" bundle:nil];          sec.name = self.ttbName.text;     sec.password = self.ttbPassword.text;     [self.navigationController pushViewController:sec animated:YES]; }  - (IBAction)ttbCancel:(id)sender {     [self.ttbName resignFirstResponder];     [self.ttbPassword resignFirstResponder];     self.ttbPassword.text = @"";     self.ttbName.text = @""; }  - (IBAction)resign:(id)sender {     [self.ttbName resignFirstResponder];     [self.ttbPassword resignFirstResponder]; } @end

3.创建详细信息显示视图,命名为ReturnViewController,带有xib文件


ReturnViewController.h:

#import <UIKit/UIKit.h>  @interface ReturnViewController : UIViewController @property (retain, nonatomic) IBOutlet UILabel *lblName; @property (retain, nonatomic) IBOutlet UILabel *lblPassword;  @property(copy,nonatomic)NSString *name; @property(copy,nonatomic)NSString *password; - (IBAction)return:(id)sender;  @end

ReturnViewController.m:

#import "ReturnViewController.h"  @interface ReturnViewController ()  @end  @implementation ReturnViewController  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];     if (self) {         // Custom initialization     }     return self; }  -(void)viewWillAppear:(BOOL)animated {     //隐藏导航栏     [self.navigationController setNavigationBarHidden:YES animated:YES]; //    UIImage *imge = [UIImage imageNamed:@"psu.gif"]; //    self.img = [[UIImageView alloc] initWithImage:imge];     self.lblName.text = self.name;     self.lblPassword.text = self.password; }  - (void)viewDidLoad {     [super viewDidLoad];     UIImage *image = [UIImage imageNamed:@"psu.gif"];     UIImageView *picView = [[UIImageView alloc] initWithImage:image];     [self.view insertSubview:picView atIndex:13];     picView.frame = CGRectMake(92, 161, 136, 115); }    - (void)dealloc {     [_lblName release];     [_lblPassword release];     [super dealloc]; } - (IBAction)return:(id)sender {     [self.navigationController popToRootViewControllerAnimated:YES]; }  @end 


项目源码:http://download.csdn.net/detail/s10141303/5991219





















本文转蓬莱仙羽51CTO博客,原文链接:http://blog.51cto.com/dingxiaowei/1366425 ,如需转载请自行联系原作者
相关文章
|
6月前
|
小程序
微信小程序实现不同按钮跳转同一个页面显示不同内容
微信小程序实现不同按钮跳转同一个页面显示不同内容
145 0
|
5月前
|
JavaScript
技术心得:根据不同访问设备跳转到PC页面或手机页面
技术心得:根据不同访问设备跳转到PC页面或手机页面
63 0
|
6月前
|
定位技术 iOS开发
iphone4s经过地图页面直接跳转到其它页面导致页面不能正常加载
iphone4s经过地图页面直接跳转到其它页面导致页面不能正常加载
35 0
|
小程序 JavaScript 定位技术
小程序点击指定地址按钮直接打开地图导航
小程序点击指定地址按钮直接打开地图导航
257 0
|
前端开发 JavaScript
漏刻有时后台左侧菜单默认隐藏的解决方案
漏刻有时后台左侧菜单默认隐藏的解决方案
70 0
|
Java 数据库
通过窗口看世界之 界面制作如此简单-带你制作旅游观光系统界面-----效果图展示
通过窗口看世界之 界面制作如此简单-带你制作旅游观光系统界面-----效果图展示
127 0
|
安全 Java 数据库
页面控制菜单的显示或隐藏|学习笔记
快速学习页面控制菜单的显示或隐藏
页面控制菜单的显示或隐藏|学习笔记
|
iOS开发
iOS开发 - 使用UISearchController跳转新控制器时搜索框依然出现
iOS开发 - 使用UISearchController跳转新控制器时搜索框依然出现
134 0
|
定位技术 API 开发工具
百度地图开发-显示地图默认界面 03
百度地图开发-显示地图默认界面 03
288 1
百度地图开发-显示地图默认界面 03
|
编解码
根据用户浏览页面的设备和屏幕的分辨率,在页面上显示不同的页面和不同大小的图片
根据用户浏览页面的设备和屏幕的分辨率,在页面上显示不同的页面和不同大小的图片
147 0
根据用户浏览页面的设备和屏幕的分辨率,在页面上显示不同的页面和不同大小的图片