iOS登陆界面
武汉市房屋出租-台北人读后感
ios 登陆界面 (在iOS代码库中浏览本帖)
开发环境:Xcode5,
支持IOS5.1+
阅读先决条件: 了解MainStory,会使用Segue进行界面跳转
登陆界面效果:
登陆界面优化:
0. 当键盘出现,点击空白处,键盘消失。
1. 键盘出现,界面自动偏移, 键盘消失,界面自动恢复。 IQKeyboardManager
2. 登陆网络不好的时候,实现进度条提示。
MBProgressHUD
新建工程Login工程,中间省略部分操作。
优化0:
在loginViewController.h中
- (void)viewDidLoad
{
[super viewDidLoad];
HUD = [[MBProgressHUD alloc] initWithView:];
[ addSubview:HUD];
te = self;
ext = @登录中...
tap for dismissing keyboard
UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(dismissKeyboard)];
[
addGestureRecognizer:tap];
very important
make delegate useful
te = self;
}
tap dismiss keyboard
-(void)dismissKeyboard {
[
endEditing:YES];
[rdTF
resignFirstResponder];
}
优化1:
1)
在loginAppDelegate.h中引入IQKeyboardManager
2)
在loginAppDelegate.m中application
didFinishLaunching方法添加以下代码即可
Override
point for customization after application launch.
ONE LINE OF CODE.
Enabling keyboard manager(Use this line to enable
managing distance between
keyboard &
textFieldtextView).
[[IQKeyboardManager
sharedManager] setEnable:YES];
(Optional)Set Distance between keyboard &
textField, Default is 10.
[[IQKeyboardManager sharedManager]
setKeyboardDistanceFromTextField:50];
(Optional)Enable autoToolbar behaviour. If
It is set to NO. You have to manuall
y create
UIToolbar for keyboard.
[[IQKeyboardManager sharedManager]
setEnableAutoToolbar:YES];
(Optional)Setting toolbar behaviour to
IQAutoToolbarBySubviews to manage previ
ousnext
according to UITextField's hirarchy in it's
SuperView. Set it to IQAutoTo
olbarByTag to
manage previousnext according to UITextField's tag
property in incre
asing order.
[[IQKeyboardManager sharedManager] setToolbarManag
eBehaviour:IQAutoToolbar
BySubviews];
(Optional)Resign textField if touched
outside of UITextFieldUITextView.
[[IQKeyboardManager sharedManager]
setShouldResignOnTouchOutside:YES];
(Optional)Giving permission to
modify TextView's frame
[[IQKeyboardManager sharedManager]
setCanAdjustTextView:YES];