zoukankan      html  css  js  c++  java
  • keyboard和 UITextFiled 之间的处理

    //在 viewDidLoad注册通知监听keyboard 的弹出

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(KeyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];

     

    //键盘改变 frame 的时候会调用地方法;

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

        NSLog(@"%@",noti);

        //设置窗口的颜色;

        self.view.window.backgroundColor = [UIColor whiteColor];

        //取出键盘弹出用的时间;

        CGFloat durtion = [noti.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];

        //键盘最后的 frame

        CGRect keyFrame = [noti.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

    //键盘在 view 上高度的变化;

        CGFloat tranformH = keyFrame.origin.y - self.view.frame.size.height;

    //改变时动画延时;

        [UIView animateWithDuration:durtion animations:^{

            self.view.transform = CGAffineTransformMakeTranslation(0, tranformH);

        }];

    }

     //在 tableView 滑动的时候 keyboard 隐藏,此时要遵循 scrollerViewDelegate;(uitableVIewDetelate 也行)

    #pragma scrollerViewDelegate;

    - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {

        //结束编辑, keyboard 回收;

        [self.view endEditing:YES];

        //[UIView animateWithDuration:0.25 animations:^{

           // self.view.transform = CGAffineTransformMakeTranslation(0, 216);

      //  }];

    }

  • 相关阅读:
    三元表达式、列表推导式、生成器表达式、递归、匿名函数
    nonlocal关键字、装饰器
    函数嵌套、作用域、闭包
    实参和形参
    函数基础
    文件操作
    字符编码
    推荐一个纯JavaScript编写的图表库——Highcharts
    推荐web 前端代码的编辑分享平台——RunJS
    了解腾讯
  • 原文地址:https://www.cnblogs.com/chamton/p/4903420.html
Copyright © 2011-2022 走看看