zoukankan      html  css  js  c++  java
  • 如何在键盘出现时滚动表格,以适应输入框的显示

    1. //  
    2. - (void)registerForKeyboardNotifications {  
    3.   [[NSNotificationCenter defaultCenter] addObserver:self  
    4.                                            selector:@selector(keyboardWillShow:)  
    5.                                                name:UIKeyboardWillShowNotification  
    6.                                              object:nil];  
    7.     
    8.   [[NSNotificationCenter defaultCenter] addObserver:self  
    9.                                            selector:@selector(keyboardWillHide:)  
    10.                                                name:UIKeyboardWillHideNotification  
    11.                                              object:nil];  
    12.   return;  
    13. }  
    14.   
    15. - (void)keyboardWillShow:(NSNotification *) notif {  
    16.   NSDictionary *info = [notif userInfo];  
    17.   NSValue *value = [info objectForKey:UIKeyboardFrameBeginUserInfoKey];  
    18.   CGSize keyboardSize = [value CGRectValue].size;  
    19.   [_tableView setContentOffset:CGPointMake(_tableView.contentOffset.x,  
    20.                                            _tableView.contentOffset.y + keyboardSize.height + 10)  
    21.                       animated:YES];  
    22.   return;  
    23. }  
    24.   
    25. - (void)keyboardWillHide:(NSNotification *) notif {  
    26.   NSDictionary *info = [notif userInfo];  
    27.   NSValue *value = [info objectForKey:UIKeyboardFrameBeginUserInfoKey];  
    28.   CGSize keyboardSize = [value CGRectValue].size;  
    29.   [_tableView setContentOffset:CGPointMake(_tableView.contentOffset.x,  
    30.                                            _tableView.contentOffset.y - keyboardSize.height - 10)  
    31.                       animated:YES];  
    32.   return;  
    33. }  
  • 相关阅读:
    6-4.粗体标签
    [Unity3D] 如何实现点击按钮退出游戏
    [Unity3D] 载入游戏地图时背景图片随机切换 & 数字百分比进度条
    [Unity3D] 鼠标点击图片移动效果
    [3DMAX]如何将骨骼与模型绑定在一起(蒙皮) & 如何实现自动化人物模型蒙皮
    [Unity 3D]用鼠标滚轮实现镜头放大和缩放,并添加距离限制
    [Unity3D] 如何实现围绕旋转
    [Unity3D] 如何实现注视旋转
    Css 图片自适应
    Scss 定义内层class的简单写法
  • 原文地址:https://www.cnblogs.com/fengmin/p/5015854.html
Copyright © 2011-2022 走看看