zoukankan      html  css  js  c++  java
  • UITextField弹出键盘挡住输入框问题

    //开始编辑输入框的时候,软键盘出现,执行此事件

    -(void)textFieldDidBeginEditing:(UITextField *)textField

    {

        CGRect frame = [textField convertRect:textField.frame toView:self.view];

      //上移数值,根据自己情况调整

        int offset = frame.origin.y - 100 - (UISCROEEN_SIZE.height - 216.0);//键盘高度216

        

        NSTimeInterval animationDuration = 0.30f;

        [UIView beginAnimations:@"ResizeForKeyboard" context:nil];

        [UIView setAnimationDuration:animationDuration];

        

        //将视图的Y坐标向上移动offset个单位,以使下面腾出地方用于软键盘的显示

        if(offset > 0)

            self.view.frame = CGRectMake(0.0f, -offset, UISCROEEN_SIZE.width, UISCROEEN_SIZE.height);

        

        [UIView commitAnimations];

    }

    //输入框编辑完成以后,将视图恢复到原始状态

    -(void)textFieldDidEndEditing:(UITextField *)textField

    {

        self.view.frame = CGRectMake(0, 0, UISCROEEN_SIZE.width, UISCROEEN_SIZE.height);

    }

    - (BOOL)textFieldShouldReturn:(UITextField *)textField

    {

        [textField resignFirstResponder];

        return YES;

    }

  • 相关阅读:
    hadoop2.2.0+hive-0.10.0完全分布式安装方法
    linux之vim编辑器
    hive与hbase的区别与联系
    linux系统管理
    Hive 自定义函数(转)
    hive 存储格式
    ActiveMQ 使用spring模板 发布消息过程分析
    ActiveMQ spring (一)
    ActiveMQ 权限(二)
    ActiveMQ 权限(一)
  • 原文地址:https://www.cnblogs.com/qianyindichang/p/3997853.html
Copyright © 2011-2022 走看看