iOS 当键盘覆盖textFiled时简单的处理方法
//方法1---
- (void)textFieldDidBeginEditing:(UITextField *)textField {
if (iPhone5) {
return;
}
else
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
//设定动画开始时的状态为目前画面上的样子
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x,
self.view.frame.origin.y - 70,
self.view.frame.size.width,
self.view.frame.size.height);
[UIView commitAnimations];
}
}
//方法2---scrollView
-(void)textViewDidBeginEditing:(UITextView *)textView
{
if (iPhone5)
{
//改变当前的滚动位置
[self.myScroll setContentOffset:CGPointMake(0,phoneNumberTextFiled.frame.origin.y-190) animated:YES];
}
else
{
//改变当前的滚动位置
[self.myScroll setContentOffset:CGPointMake(0,phoneNumberTextFiled.frame.origin.y-100) animated:YES];
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。