ios登陆界面
2015-10-12 18:43
435 查看
代码较老,仅供参考
主要涉及的功能点有:
1、密码输入框要隐藏输入字符,以黑点代替,有时候会在边上设置一个按钮,让用户选择是否需要密文输入
2、Login时会检查输入框,若输入不合法,弹窗提示用户
3、Reset会清空输入
4、点击界面空白地方的时候,能够收起输入键盘,防止挡住用户点击登陆
5、弹出键盘要对输入框适配,来保证输入框不被键盘挡住
1、对于要隐藏输入的文本框,我们只需要把其secureTextEntry的属性设置为TRUE就行了:
Object-c代码
self.password.secureTextEntry=TRUE;
2、Login功能会把用户输入保存到AppDelegate中,这样以后程序中需要的时候还可以取到:
-(IBAction)login:(id)sender{
NSString *userName = [self.userName.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *password = [self.password.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if(userName.length==0||password.length==0){
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"Input invalid" message:@"UserName or Password is empty" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}
[delegate.userState setObject:userName forKey:@"KUserName"];
[delegate.userState setObject:password forKey:@"KPassword"];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.window.rootViewController = appDelegate.tabBar;
}
3、在Reset时,除了清空UI控件中的内容,还需要清空AppDelegate中的内容:
-(IBAction)reset:(id)sender{
self.userName.text=@"";
self.password.text=@"";
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.userState setObject:@"" forKey:@"KUserName"];
[delegate.userState setObject:@"" forKey:@"KPassword"];
}
所有与UI空间绑定的方法都需要返回类型IBAction
主要涉及的功能点有:
1、密码输入框要隐藏输入字符,以黑点代替,有时候会在边上设置一个按钮,让用户选择是否需要密文输入
2、Login时会检查输入框,若输入不合法,弹窗提示用户
3、Reset会清空输入
4、点击界面空白地方的时候,能够收起输入键盘,防止挡住用户点击登陆
5、弹出键盘要对输入框适配,来保证输入框不被键盘挡住
1、对于要隐藏输入的文本框,我们只需要把其secureTextEntry的属性设置为TRUE就行了:
Object-c代码
self.password.secureTextEntry=TRUE;
2、Login功能会把用户输入保存到AppDelegate中,这样以后程序中需要的时候还可以取到:
-(IBAction)login:(id)sender{
NSString *userName = [self.userName.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *password = [self.password.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if(userName.length==0||password.length==0){
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"Input invalid" message:@"UserName or Password is empty" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}
[delegate.userState setObject:userName forKey:@"KUserName"];
[delegate.userState setObject:password forKey:@"KPassword"];
AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.window.rootViewController = appDelegate.tabBar;
}
3、在Reset时,除了清空UI控件中的内容,还需要清空AppDelegate中的内容:
-(IBAction)reset:(id)sender{
self.userName.text=@"";
self.password.text=@"";
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.userState setObject:@"" forKey:@"KUserName"];
[delegate.userState setObject:@"" forKey:@"KPassword"];
}
所有与UI空间绑定的方法都需要返回类型IBAction
相关文章推荐
- fir.im Weekly - 给女朋友的 iOS 开发教程
- fir.im Weekly - 给女朋友的 iOS 开发教程
- 项目适配iOS9遇到的一些问题及解决办法(更新两个小问题)
- iOS 开发 是该选择Block 还是Delegate呢
- ios测试基础二:mac 安装并使用git下载代码步骤
- iOS7 新特性 edgesForExtendedLayout
- ios vfl代码布局
- iOS软件开发 快速将p12文件转pem
- ios9 3dtouch 博客
- iOS 这一段时间的感悟
- iOS 导航栏navigation的translucent属性 影响半透明状态
- iOS之错误总结收集
- iOS 各种控件默认高度(图示)
- iOS 9隐藏状态栏动画setStatusBarHidden(_:withAnimation:) deprecated
- iOS中AutoLayer自动布局流程及相关方法
- ios图片模糊效果
- iOS OpenCV 缺少64位解决方法
- IOS Quartz 各种绘制图形用法---实现画图片、写文字、画线、椭圆、矩形、棱形等
- iOS iPhone 添加 摇一摇后 让手机震动或者铃声设置
- iOS 修改图片的亮度、对比度、饱和度