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];
    }
  • 相关阅读:
    linux mint安装成功
    js 兼容性
    程序员的肚子有多大,水平就有多高
    财富通直连接口for rails3
    ubuntu live cd版本是没有recuse broken system功能
    生活百科
    省市县导入mysql代码,通过csv
    省市县导入mysql代码,通过csv
    休眠、挂起、待机三者之间的区别 收藏
    支付宝接口for rails3
  • 原文地址:https://www.cnblogs.com/Clin/p/3199349.html
Copyright © 2011-2022 走看看