概述实现以下三个方法,如果d出的
键盘会
遮住输入框 ,整体的界面会向上移动,这样就不会遮住输入框了。自己增加UITextFieldDelegate委托。 只适合iPhone,如果想要支持iPad,只要把216改成iPad上面键盘的高度即可。 - (void)keyboardWillShow:(NSNotification *)noti { //键盘输入的界面调整 实现以下三个方法,如果d出的键盘会遮住输入框 ,整体的界面会向上移动,这样就不会遮住输入框了。自己增加UITextFIEldDelegate委托。 只适合iPhone,如果想要支持iPad,只要把216改成iPad上面键盘的高度即可。 - (voID)keyboarDWillShow:(NSNotification *)noti { //键盘输入的界面调整 //键盘的高度 float height = 216.0; CGRect frame = self.vIEw.frame; frame.size = CGSizeMake(frame.size.wIDth,frame.size.height - height); [UIVIEw beginAnimations:@"Curl"context:nil];//动画开始 [UIVIEw setAnimationDuration:0.30]; [UIVIEw setAnimationDelegate:self]; [self.vIEw setFrame:frame]; [UIVIEw commitAnimations]; } - (BOol)textFIEldShouldReturn:(UITextFIEld *)textFIEld { // When the user presses return,take focus away from the text fIEld so that the keyboard is dismissed. NSTimeInterval animationDuration = 0.30f; [UIVIEw beginAnimations:@"ResizeforKeyboard" context:nil]; [UIVIEw setAnimationDuration:animationDuration]; CGRect rect = CGRectMake(0.0f,0.0f,self.vIEw.frame.size.wIDth,self.vIEw.frame.size.height); self.vIEw.frame = rect; [UIVIEw commitAnimations]; [textFIEld resignFirstResponder]; return YES; } - (voID)textFIEldDIDBeginEditing:(UITextFIEld *)textFIEld { CGRect frame = textFIEld.frame; int offset = frame.origin.y + 32 - (self.vIEw.frame.size.height - 216.0);//键盘高度216 NSTimeInterval animationDuration = 0.30f; [UIVIEw beginAnimations:@"ResizeforKeyBoard" context:nil]; [UIVIEw setAnimationDuration:animationDuration]; float wIDth = self.vIEw.frame.size.wIDth; float height = self.vIEw.frame.size.height; if(offset > 0) { CGRect rect = CGRectMake(0.0f,-offset,wIDth,height); self.vIEw.frame = rect; } [UIVIEw commitAnimations]; } 总结
以上是内存溢出为你收集整理的UITextField控件处理键盘d出时遮住输入框的问题。全部内容,希望文章能够帮你解决UITextField控件处理键盘d出时遮住输入框的问题。所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)