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);

      //  }];

    }

  • 相关阅读:
    iOS-iOS8模拟器设置中文键盘
    iOS-应用性能调优的25个建议和技巧
    IOS-通讯录
    IOS-录音
    IOS-视频
    IOS-音乐
    IOS-音效
    iOS开发实用技巧—Objective-C中的各种遍历(迭代)方式
    Android 带你玩转实现游戏2048 其实2048只是个普通的控件(转)
    Android TagFlowLayout完全解析 一款针对Tag的布局(转)
  • 原文地址:https://www.cnblogs.com/chamton/p/4903420.html
Copyright © 2011-2022 走看看