`
jsntghf
  • 浏览: 2480037 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

UITextField控件处理键盘弹出时遮住输入框的问题

    博客分类:
  • iOS
阅读更多
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    float offset = 0.0f;
    if(self.grade == textField || self.tel == textField)
    {
        offset = - 180.0f;
    }
    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;
    CGRect rect = CGRectMake(0.0f, offset , width, height);
    self.view.frame = rect;
    [UIView commitAnimations];
}

 

这样,当编辑grade或者tel时,视图会自动滚动到当前的TextField。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics