zoukankan      html  css  js  c++  java
  • uiviewcontroller 键盘不遮挡信息

    //添加监听事件
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
    //监听回调
    #pragma mark - keyboard 
    - (void)keyboardWillShow:(NSNotification*)notification {
    
        CGRect frame = self.view.frame;
        frame.origin.y -= 166;
        //frame.size.height +=216;
        // Shrink view's inset by the keyboard's height, and scroll to show the text field/view being edited
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
        [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
        self.view.frame = frame;
        [UIView commitAnimations];
    }
    
    - (void)keyboardWillHide:(NSNotification*)notification {
    
        CGRect frame = self.view.frame;
        frame.origin.y += 166;
        //frame.size.height -=216;
        //self.view移回原位置
        // Restore dimensions to prior size
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
        [UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
        self.view.frame = frame;
        [UIView commitAnimations];
    }
  • 相关阅读:
    Struts2结合Ajax实现登录
    Java读取Properties文件
    职责链模式
    javaScript初学者易错点
    2019 DevOps 必备面试题——DevOps 理念篇
    如何成为一名优秀的敏捷团队负责人
    为什么企业敏捷团队会失败
    伪装的敏捷,我好累
    CODING 告诉你如何建立一个 Scrum 团队
    十倍程序员的传说
  • 原文地址:https://www.cnblogs.com/Clin/p/3199349.html
Copyright © 2011-2022 走看看