zoukankan      html  css  js  c++  java
  • IOS键盘弹出、隐藏

    IOS键盘

    • UIKeyboardFrameBeginUserInfoKey:动画开始前键盘的size
    • UIKeyboardFrameEndUserInfoKey:动画结束后键盘的size
    - (void)registeKeyboardNotification
    {
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWasShown:)
                                                     name:UIKeyboardDidShowNotification object:nil];
        
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(keyboardWillBeHidden:)
                                                     name:UIKeyboardWillHideNotification object:nil];
    }
    
    - (void)unRegisteKeyboardNotification
    {
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }
    
    - (void)keyboardWasShown:(NSNotification*)aNotification
    {
        NSDictionary* info = [aNotification userInfo];
        // 动画结束后键盘的size
        CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
           
        UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
        scrollView.contentInset = contentInsets;
        scrollView.scrollIndicatorInsets = contentInsets;
        
        // frame为scrollView要滑动到的位置
        CGRect frame;
        [scrollView scrollRectToVisible:frame animated:YES];
    }
    
    // Called when the UIKeyboardWillHideNotification is sent
    - (void)keyboardWillBeHidden:(NSNotification*)aNotification
    {
        UIEdgeInsets contentInsets = UIEdgeInsetsZero;
    
        scrollView.contentInset = contentInsets;
        scrollView.scrollIndicatorInsets = contentInsets;
    }
    
  • 相关阅读:
    js类型转换 枫
    AspNetPager操作示例1 枫
    discuz资料 枫
    Request.params的知识 枫
    C#实现自动锁屏+关屏 枫
    iis访问aspx文件显示404无法找到文件? 枫
    filter:alpha(opacity=100,style=1) 枫
    IIS安装程序无法复制文件的问题(转载) 枫
    DataTable 枫
    windows系统函数详解(控制面板等常用函数) 枫
  • 原文地址:https://www.cnblogs.com/java-koma/p/4933138.html
Copyright © 2011-2022 走看看