只适合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];
}
- (IBAction) backgroundTap:(ID)sender{
[remarksFIEld resignFirstResponder];
[self textFIEldShouldReturn:remarksFIEld];
}
总结以上是内存溢出为你收集整理的[UI控件问题] UITextField控件处理键盘d出时遮住输入框的问题全部内容,希望文章能够帮你解决[UI控件问题] UITextField控件处理键盘d出时遮住输入框的问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)