zoukankan      html  css  js  c++  java
  • 遮挡键盘

    #pragma mark — 键盘遮挡

    -(void)createNotifiticationCenter
    {
    //创建通知中心
    NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
    //键盘弹出
    [center addObserver:self selector:@selector(receivesKeyBordShowNotification:) name:UIKeyboardWillShowNotification object:nil];

    //监听键盘收回时发送的通知
    [center addObserver:self selector:@selector(receivesKeyBordHiddenNotification:) name:UIKeyboardWillHideNotification object:nil];
    }

    -(void)receivesKeyBordShowNotification:(NSNotification *)noti
    {

    //取出键盘的弹起时间
    NSTimeInterval time = [[noti.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey]doubleValue];
    //在键盘的这段时间内将界面上的控件上移

    //使用动画
    [UIView animateWithDuration:time delay:0 options:0 animations:^{
    //将界面整体上移
    CGRect boubds = self.view.bounds;
    boubds.origin.y = 70;
    self.view.bounds = boubds;
    } completion:^(BOOL finished) {

    }];
    }

    -(void)receivesKeyBordHiddenNotification:(NSNotification *)notifi
    {
    //从通知信息体取出键盘收回的时间
    NSTimeInterval time = [[notifi.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey]doubleValue];

    //用动画将界面下移
    [UIView animateWithDuration:time delay:0 options:0 animations:^{
    CGRect bounds = self.view.bounds;
    bounds.origin.y = 0;
    self.view.bounds = bounds;
    } completion:^(BOOL finished) {

    }];
    }

    - (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    }

  • 相关阅读:
    HTTP协议
    安全测试-渗透性测试
    网络安全、Web安全、渗透测试之笔经面经总结(三)
    Struts2拦截器再认识
    struts2.5+框架使用通配符与动态方法
    struts.xml配置详解
    代理概述
    Mybatis Plugin(拦截器)的开发
    详解环境搭建SSM
    mybatis-databaseIdProvider多数据库支持
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5614685.html
Copyright © 2011-2022 走看看