zoukankan      html  css  js  c++  java
  • 显示keyboard及输入框上移

    #pragma mark -

    #pragma mark Keyboard notifications from Apple's UICatalog example

    //The code comes straight from Apple's UICatalog example, except that I have modified the UI manipulation

    //to use bounds instead of frame, so that when keyboard is shown, the view "scrolls" to the right place

    //so that the input field would remain visible.

    - (void)keyboardWillShow:(NSNotification *)aNotification {

      // the keyboard is showing so resize the my height

      CGRect keyboardRect = [[[aNotification userInfoobjectForKey:UIKeyboardBoundsUserInfoKeyCGRectValue];

      NSTimeInterval animationDuration = [[[aNotification userInfoobjectForKey:UIKeyboardAnimationDurationUserInfoKey]                            doubleValue];

     

      CGRect bounds = self.view.bounds;

      bounds.origin.y += keyboardRect.size.height;

     

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

      [UIView setAnimationDuration:animationDuration];

       self.view.bounds = bounds;

      [UIView commitAnimations];

    }

     

    - (void)keyboardWillHide:(NSNotification *)aNotification {

      // the keyboard is hiding reset the table's height

       CGRect keyboardRect = [[[aNotification userInfoobjectForKey:UIKeyboardBoundsUserInfoKeyCGRectValue];

      NSTimeInterval animationDuration = [[[aNotification userInfoobjectForKey:UIKeyboardAnimationDurationUserInfoKey]                            doubleValue];

       CGRect bounds = self.view.bounds;

       bounds.origin.y -= keyboardRect.size.height;

     

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

      [UIView setAnimationDuration:animationDuration];

      self.view.bounds = bounds;

      [UIView commitAnimations];

    }


  • 相关阅读:
    ubuntu18.04阿里源
    C# 去开头字符串
    思维导图 电商运营思路
    思维导图 淘宝淘宝流量来源
    学习 名词
    Java面试题之“==”和“equals()”方法的区别?
    修改本地MySQL的root身份密码
    添加并启动MySQL服务
    在centos7上进行hadoop-3.1.2的伪分布搭建
    TreeMap树映射取出对象的方式
  • 原文地址:https://www.cnblogs.com/eagley/p/1743492.html
Copyright © 2011-2022 走看看