zoukankan      html  css  js  c++  java
  • iOS TextField输入框点击键盘时随着键盘上移

    -(void)textFieldDidBeginEditing:(UITextField *)textField

    {

        CGRect frame = textField.frame;

        int offset = frame.origin.y + 70  - (self.view.frame.size.height -216.0);//iPhone键盘高度216,iPad的为352

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

        [UIView setAnimationDuration:0.5f];

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

        if(offset > 0)

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

        [UIView commitAnimations];

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

    -(void)textFieldDidEndEditing:(UITextField *)textField

    {

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

    }

  • 相关阅读:
    Sherlock and Squares
    [leetcode] Super Ugly Number
    [leetcode] Ugly Number II
    [leetcode] Ugly Number
    [leetcode] Burst Balloons
    菜根谭#268
    菜根谭#267
    菜根谭#266
    菜根谭#265
    菜根谭#264
  • 原文地址:https://www.cnblogs.com/sunfuyou/p/6144406.html
Copyright © 2011-2022 走看看