UItextField键盘弹出

//首先注册通知,键盘出现和消失的通知

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardAppear:) name:UIKeyboardWillShowNotification object:nil];  [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardDisappear:) name:UIKeyboardWillHideNotification object:nil];

完成响应事件

#pragma mark KeyBoard appear and disAppear

-(void)keyboardAppear:(NSNotification *)aNotification

{

[UIView beginAnimations:nil context:nil];

//设定动画持续时间

[UIView setAnimationDuration:0.3];

NSDictionary *userInfo = [aNotification userInfo];

NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

CGRect keyboardRect = [aValue CGRectValue];

int height = keyboardRect.size.height;//键盘的高度

//动画的内容

[tintAndCheckAnswerButtonView setFrame:CGRectMake(0,self.frame.size.height-height-tintAndCheckAnswerButtonView.frame.size.height,tintAndCheckAnswerButtonView.frame.size.width, tintAndCheckAnswerButtonView.frame.size.height)];

//动画结束

[UIView commitAnimations];

}

-(void)keyboardDismiss:(NSNotification *)no

{

[UIView beginAnimations:nil context:nil];

//设定动画持续时间

[UIView setAnimationDuration:0.3];

//动画的内容

[tintAndCheckAnswerButtonView setFrame:orignalTintAndCheckButton_ViewFrame];

//动画结束

[UIView commitAnimations];

}

UItextField键盘弹出,布布扣,bubuko.com

时间: 2024-07-31 14:30:29

UItextField键盘弹出的相关文章

键盘弹出与隐藏对TextView的影响

今天下午写了个Demo,让键盘弹出时整个View上移,隐藏时整个View回到原位.用通知做的 1 #import "ViewController.h" 2 3 @interface ViewController () 4 @property(nonatomic, strong)UITextField *textView; 5 @property(nonatomic, strong)UIButton *btn; 6 @end 7 8 @implementation ViewControl

键盘的出现于隐藏(解决键盘弹出时会覆盖文本框的问题,代码实现)

#import "ViewController.h" #import "UIView+FrameExtension.h" // 可以自己写,以后用着方便 #define kDeviceHeight [UIScreen mainScreen].bounds.size.height @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super v

iOS开发,使用Category实现键盘弹出时,移动View以防被遮住

嗯,直接上代码!!!! 这是.h文件的 #import <UIKit/UIKit.h> @interface UIView (AboutKeyboard) @property (nonatomic) CGFloat moveDistince; @property (nonatomic) UIView *moveView; /* *指定一个View在键盘出现和消失时移动,如果存在superView则移动superView,否则移动自身 */ - (void)registerWhenKeyboar

iOS开发中如何在键盘弹出时改变View的高度

在iOS开发的时候有两个经常要用到的控件UITextfield跟UITextView,我们输入内容基本是通过这两个控件进行的,但是有时候会遇到这样的问题:在点击输入之后弹出键盘遮盖住了输入框,可以通过以下办法解决: 添加通知监听键盘的弹出跟隐藏 //监听键盘弹出和隐藏 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillSho

【apicloud问题解决记录】键盘弹出监听处理以及头部底部的黑色闪屏现象

http://blog.csdn.net/kongjiea/article/details/46545351 移动端解决fixed和input获取焦点软键盘弹出影响定位的问题 使用apicloud开发中并不存在这个问题,input进行焦点获取,页面会自动压缩 apicloud,使用api.openWin()打开win框架后,如果bounces:true会出现向下拉和向上拉黑屏和闪屏现象. 打开openWin({bounces:false}),再在win里面打开frame框架 以下面新浪新闻页为例

如何解决软键盘弹出引起的各种不适

1.如何解决软键盘弹出引起的各种不适 2.android软键盘弹出引起的各种不适终极解决方案 3.android软键盘弹出引起的各种不适终极解决方案 4.android软键盘弹出,会把原来的界面挤上去的问题 处理方法 5.Android 关于弹出键盘问题的几种情况和解决方案 6.Android 弹出软键盘问题(最终解决方法) 7.Android 软键盘显示隐藏监听解决方案

键盘弹出的现象

- (void)keyboardWillChange:(NSNotification  *)notification { /* userInfo = { // 键盘弹出的节奏 UIKeyboardAnimationCurveUserInfoKey = 7; //键盘弹出执行动画的时间 UIKeyboardAnimationDurationUserInfoKey = "0.25";      UIKeyboardBoundsUserInfoKey = "NSRect: {{0,

android软键盘弹出引起的各种不适终极解决方案

很多写登录界面的开发者都会遇到一个问题:那就是在登录界面时,当你点击输入框时,下边的按钮有时会被输入框挡住,这个不利于用户的体验,所以很多人希望软键盘弹出时,也能把按钮挤上去.很多开发者想要监听键盘的状态,这无疑是一个很麻烦的做法. 我们可以在AndroidManifest.xml的Activity设置属性:android:windowSoftInputMode = "adjustResize" ,软键盘弹出时,要对主窗口布局重新进行布局,并调用onSizeChanged方法,切记一点

Android软键盘弹出,布局移动

在项目的androidmanifest.xml文件中界面对应的<activity>里加入 android:windowsoftinputmode="adjustpan"这样键盘就会覆盖屏幕.. 如果不想键盘覆盖屏幕,想让屏幕整体上移,就加入属性android:windowsoftinputmode="statevisible|adjustresize" Android软键盘弹出,布局移动,布布扣,bubuko.com